How to get argument from url in flutter web using get: ^3.26.0

Issue

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.

Solution

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'];

Answered By – Jayesh Pansheriya

Answer Checked By – Mary Flores (FlutterFixes Volunteer)

Leave a Reply

Your email address will not be published.