The argument type 'User?' can't be assigned to the parameter type 'Future<Object?>?'
I don't typically do that with a FutureBuilder. Once you have a user, you don't need to async it.
final FirebaseAuth_auth = FirebaseAuth.instance();
final User? user;
user = _auth.currentUser;
Then, if user != null ....create your ListView else, return a CircularProgressIndicator or whatever.
Look up Net Ninja for some nice videos for getting yourself set up with all that, just having a stream based on userChanges() for your project. More robust setup.
Ahsan Naushad
Updated on December 22, 2022Comments
-
Ahsan Naushad over 1 year
With reference to the recent changes regarding
FirebaseUser
toUser
.FirebaseAuth.instance.currentUser()
is not found at all (while throughing error "The expression doesn't evaluate to a function, so it can't be invoked."
The solution to that however was to simply remove the paranthesis asFirebaseAuth.instance.currentUser
. But now we have another error that it isn't a future type i.e "The argument typeUser
can't be assigned to the parameter typeFuture<Object?>?
".
Following is my code block.return FutureBuilder( future: FirebaseAuth.instance.currentUser, builder: (ctx, futureSnapshot) => ListView.builder( reverse: true, // So that 1st message goes to last. itemCount: chatDocument.length, itemBuilder: (ctx, index) => MessageBubble( message: chatDocument[index]['text'], isMe: chatDocument[index]['userId'], ), ), );
In the above code block I intend to provide future to my `FutureBuilder`. In summary previously `FirebaseUser` object did return a future, but probably `User` doesn't anymore. How may I handle this case?
Thanks in advance.-
Fatima ayaa almost 3 yearsyou have to remove FutureBuilder , and use FirebaseAuth.instance.currentUser syimply because it is not a Future
-
Ahsan Naushad almost 3 yearsYup. That works. Thank you.
-