4
return GetMaterialApp(
      title: title,
      theme: appTheme,
      getPages: [
        GetPage(name: '/', page: () => Splash()),
        GetPage(name: '/update', page: () => Update()),
        GetPage(name: '/login', page: () => SignIn()),
        GetPage(name: '/reference', page: () => Reference()),
      ],
      home: Splash(),
    );

this is my route code and now i want to user enter url like : xyz.com/login/jayesh , then i want to get user name in login screen using getx state management.

2 Answers 2

3

In your route:

xyz.com/login?username=jayesh

And in your controller or in your view:

var username = Get.parameters["username"];

A good place to get your arguments or parameters may be in your controllers onInit or your views build method

Sign up to request clarification or add additional context in comments.

1 Comment

"A good place to get your arguments or parameters may be in your controllers onInit or your views build method" - if this really works no-one will ask such questions. "onInit" is called only once during lifecycle, after widget is allocated in memory; considering you use constant widgets for the best performance... never works as expected: subsequent calls to same route, even with different parameters, won't trigger neither "onInit" nor ""build" methods for different parameters. There are hundreds of SO questions regarding how to workaround this. Maybe I am mistaken, please prove.
1

add page with name in GetMaterialApp

getPages:[
    GetPage(name: '/login/:refId', page: () => SignIn()),    
        ],

you can retrive data(perameter) like:

var data = Get.parameters;
String id = data['refId'];

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.