I have a working repsitory on Github for this use case. The repository is working well. What I wanted to show is that I used that kind of code to run Flutter Web on website, but I cannot share the repository code as it is meant for company’s admin to run. There are a lot of secret information on the website.
My problem is a few links when get clicked, they cannot go to designation web page. It is like the link doesn’t work at all. In my case, I use
Get.rootDelegate.offNamed(Routes.LISTALBUMS);
I placed this code inside a few pages, and all of them don’t work. I changed it into Stateful Widget and add initState() to receive parameters from previous page, but it doesn’t work either. The link to this page doesn’t work at all.
Get.rootDelegate.parameters;
Meanwhile other web pages with same functional Widget do work. I used this code:
Get.rootDelegate.offNamed(Routes.REGISTEREDMENU);
This is some part the code:
//main.dart
return GetMaterialApp.router(
key: Get.key,
useInheritedMediaQuery: true,
debugShowCheckedModeBanner: false,
smartManagement: SmartManagement.full,
defaultTransition: Transition.noTransition,
getPages: AppPages.pages,
routerDelegate: AppRouterDelegate(),
routeInformationParser: GetInformationParser(
initialRoute: Routes.HOME,
),
);
//routes.dart
class AppRouterDelegate extends GetDelegate {
GetNavConfig get prevRoute => history.length < 2 ? history.last : history[history.length - 2];
@override
Future<GetNavConfig> popHistory() async {
final result = prevRoute;
Get.rootDelegate.offNamed(prevRoute.currentPage!.name);
return result;
}
@override
Widget build(BuildContext context) {
return Navigator(
reportsRouteUpdateToEngine: true,
onPopPage: (route, result) => route.didPop(result),
pages: currentConfiguration != null ? [currentConfiguration!.currentPage!] : [GetNavConfig.fromRoute(Routes.HOME)!.currentPage!],
);
}
}
2
Answers
After making some trial-error test for a few days, I found out that GetX Routing is still lacking a lot of things compared to Flutter Go Router. Finally, I know how I can combine GetMaterialApp.router with Flutter Go Router.
This is the code:
I have found the correct answer.
When I tried to send parameters into another page using
I forgot that I had 3 bool variables which I did not convert to string. So, the rule to send parameters in Getx Routing is all kinds of variables must be converted to string. This rule also valids for number, i.e.: int, double, etc. It should be something like this:
Problem is solved.