Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I combine Getx and go_router in flutter app?

I use Getx in my flutter app and want to add go router for deep link configuration. this is a part of code:

 return GetMaterialApp(
              debugShowCheckedModeBanner: false,
              title: 'App_Name',
              theme: theme,
              initialRoute: '/',
              onGenerateRoute: router.generateRoute,
              ...

I want to change top code same this:

 return GetMaterialApp.rouer(
          debugShowCheckedModeBanner: false,
          title: 'App_Name',
          theme: theme,
          routerConfig: _router,
          onGenerateRoute: router.generateRoute,
          ...

but after adding .router this command the below line can not recognize:

onGenerateRoute: router.generateRoute,

how can I combine these two part?

like image 545
Vahit Behrouz Avatar asked Sep 21 '25 04:09

Vahit Behrouz


1 Answers

return GetMaterialApp.router(
    routeInformationParser: _router.routeInformationParser,
    routerDelegate: _router.routerDelegate,
    routeInformationProvider: _router.routeInformationProvider,
    ...
);

_router is GoRouter instance

Here is the link https://github.com/jonataslaw/getx/issues/2778#issuecomment-1659779574

like image 134
Zack Avatar answered Sep 23 '25 09:09

Zack