0

I'm trying to create a FutureBuilder where the future will be the current user. Flutter is giving me an error with the line I have there now ('The expression doesn't evaluate to a function, so it can't be invoked.'). This works with an older version of the SDK but I cannot find the new version of it. I have tried removing the brackets (just having FirebaseAuth.instance.currentUser) but this gives an error 'The argument type 'User' can't be assigned to the parameter type 'Future'. Does anyone know my mistake?

FutureBuilder(
    future: FirebaseAuth.instance.currentUser(),
    builder: (ctx, futureSnapshot){

    },
  ),
Eind997
  • 319
  • 1
  • 3
  • 9
  • Try removing `()` after currentUser because you INVOKE function instead of passing a reference to it – kovalyovi Sep 12 '20 at 21:13
  • That just gives me this error 'The argument type 'User' can't be assigned to the parameter type 'Future'.' – Eind997 Sep 12 '20 at 21:16
  • The `.currentUser` is already made to be `synchronous` (it doesn't return a `Future`). So you won'r be able to use the result of `.currentUser` in a `FutureBuilder` @Eind997 – void Sep 12 '20 at 21:24
  • @void Thanks, what can I use instead? – Eind997 Sep 12 '20 at 21:45
  • 2
    You don't need to wait for it. The currentUser is returned immediately @Eind997. The question is marked duplicate and has detailed explanation from marked answer. I advice you check it out. Get the current user like this => `var user = FirebaseAuth.instance.currentUser; print(user.uid);` – void Sep 12 '20 at 21:46

0 Answers0