onGenerateRoute With await

301 views
Skip to first unread message

Tanmay Bug

unread,
Jul 14, 2020, 11:27:10 AM7/14/20
to Flutter Development (flutter-dev)

I have a Flutter app with multiple pages, some pages require the user to be logged in, in order to access the page.

The main issue I am having is, for my dashboard route I need to call an async method to check if the user is logged in and set the bool isUserLoggedIn accordingly, however, I can not call this method as it returns a future and I can not use await as the routes method can not return a future.

Any suggestions, please?

Souvik Dutta

unread,
Jul 14, 2020, 12:36:02 PM7/14/20
to Tanmay Bug, Flutter Development (flutter-dev)
Use a future builder. The future will be the function that checks if the user is logged in or not. 

--
You received this message because you are subscribed to the Google Groups "Flutter Development (flutter-dev)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flutter-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/flutter-dev/60d5d6e4-e8d6-4488-9396-5c079e19ee6cn%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages