How to get user id from Firebase Auth in Flutter?

Posted by Rohit Kumar | Updated on

If you want to get user id from Firebase Auth in Flutter? _userId is null because the widgets are being built before the Future returned by FirebaseAuth.instance.currentUser() has completed. Once it does complete it’s too late and the widgets don’t update. One way to work with it would be to use a FutureBuilder somewhat like this:


If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.

Related Questions & Answers