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

Issue

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;

Answered By – Peter Haddad

Answer Checked By – Mary Flores (FlutterFixes Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *