Does anyone know why i got the Failed assertion: boolean expression must not be null. If I had logged in and quit the app and open the app again i should be directly in the home
Your problem is that you are not waiting for your Future to resolve to an actual value.
This line:
userIsLoggedIn = value;
might not have been reached when your build method is called. Because it's async
and you don't await
it.
You can set a default value to userIsLoggedIn
, maybe false
, that will solve your immediate problem. But it will not solve your real problem, that your program logic is asynchronous.
You will probably want to build your app with at least one FutureBuilder
.
See: What is a Future and how do I use it?