Search code examples
firebaseflutterfirebase-authenticationchatflutter-futurebuilder

The argument type 'User' can't be assigned to the parameter type 'Future<dynamic>'


I am trying to build an app that contains chat, but the error message appears because this line:

 return FutureBuilder(
      future: FirebaseAuth.instance.currentUser,
The argument type 'User' can't be assigned to the parameter type 'Future<dynamic>'.

my code enter image description here


Solution

  • currentUser is a property and it returns a value of type User therefore you don't have to assign it to the future property, just do:

    User user = FirebaseAuth.instance.currentUser;