Answers for "retrieve user details in flutter"

5

getting uid of user firebase flutter

final FirebaseUser user = await auth.currentUser();
final userid = user.uid;
Posted by: Guest on May-13-2020
-1

if user is logged in or not check flutter

int main(){
   runApp(  YourApp() )
}

class YourApp extends StatelessWidget{

    @override
    Widget build(BuildContext context){
        return FutureBuilder<FirebaseUser>(
            future: FirebaseAuth.instance.currentUser(),
            builder: (BuildContext context, AsyncSnapshot<FirebaseUser> snapshot){
                       if (snapshot.hasData){
                           FirebaseUser user = snapshot.data; // this is your user instance
                           /// is because there is user already logged
                           return MainScreen();
                        }
                         /// other way there is no user logged.
                         return LoginScreen();
             }
          );
    }
}
Posted by: Guest on June-12-2021

Code answers related to "retrieve user details in flutter"

Browse Popular Code Answers by Language