Initial Route with arguments

209 views
Skip to first unread message

Mael Elvis FOSSO N.

unread,
Aug 14, 2019, 11:16:03 AM8/14/19
to Flutter Development (flutter-dev)
Hello,

I'm building an app which has a dynamic initial route.
The first time the user connects, I save its information into the device. That information must be displayed at the Login screen every time. It's is name, phone number, country code, country dial code.
I check whether that information exists in the main.dart and then I decide the open the Login screen or the Welcome screen.
As that information should be displayed in the Login screen, I wanted to pass them as arguments but when I didn't find a way to pass arguments to the initial route.

Also, when the user signs out, it's redirected at the Login screen and its information should still be displayed. Sending arguments when routing it's not a problem but how to get the routing arguments into the initState because most of those arguments should be use into the initState for example for TextEditController.text.

How could I do that, please ?

Rex Bloom

unread,
Aug 14, 2019, 11:58:06 AM8/14/19
to Mael Elvis FOSSO N., Flutter Development (flutter-dev)
I use global config data for this purpose.  Or store the information in shared_preferences and read it from the login page for display.

Rex

--
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/d6bb42eb-fc7a-4867-9fb0-55fa20b33ae4%40googlegroups.com.

Andy Greenshaw

unread,
Aug 14, 2019, 12:03:43 PM8/14/19
to Mael Elvis FOSSO N., Rex Bloom, Flutter Development (flutter-dev)
I store it (and read back from) shared_preferences as Rex suggested.
Reply all
Reply to author
Forward
0 new messages