jeudi 1 avril 2021

getting query parameter on initial route flutter

I'm working on a flutter application mainly for the web, and I'm unable to add/get the query parameter from the URL, the query parameter will contain an id, and this id should be used inside the app

this my route setup on my app state:

  return MaterialApp(navigatorKey: key,  initialRoute: '/main',
        routes: {
          // When navigating to the "/" route, build the FirstScreen widget.
          '/main': (context) => Map_View(),
          // When navigating to the "/second" route, build the SecondScreen widget.
          '/second': (context) => TaskClosed(),
        },onGenerateRoute: RouteGenerator.generateRoute,);
  }


  class RouteGenerator{
    
      static Route<dynamic> generateRoute(RouteSettings settings){
        final args = settings.arguments;
        print(args);
        var routingData = settings.name;
      }}

the settings.arguments are always null

so what should I pass to initialRoute to make it accept arguments on the first screen for example, the calling URL should be like this:

https:example.com/main?123

so how to get this parameter from the URL




Aucun commentaire:

Enregistrer un commentaire