Flutter GetX Routing Will Redirected To InitialRoute
I currently investigate the following problem: When I try to open the page the first time with link arguments like "xyz.com/invite/dd/dd" I will immediately directed to the initial route "/". When I do it in the same tab again it will work and redirect me to the given page "/invite/dd/dd".
Here the console log for the first try:
The following message was thrown:
Could not navigate to initial route.
The requested route name was: "/invite/dd/dd"
There was no corresponding route in the app, and therefore the initial route specified will be ignored and "/" will be used instead.
The console log the second try in the same tab:
[GETX] GOING TO ROUTE /dashboard
[GETX] GOING TO ROUTE /invite/dd/dd
[GETX] GOING TO ROUTE /invite/dd/dd
[log] INVITE PAGE!
It all worked fine at the second try when the page is loaded one time before!
The Sourcecode from the GetMaterialAPP in main.dart:
return GetMaterialApp(
// initialBinding: AuthBinding(),
initialRoute: RootRoute,
opaqueRoute: true,
unknownRoute: GetPage(name: "/not-found", page: () => PageNotFound(), transition: Transition.noTransition),
defaultTransition: Transition.native,
// transitionDuration: Duration.zero,
getPages: [
GetPage(name: RootRoute, page: () => Root()),
GetPage(name: AuthenticationPageRoute, page: () => AuthenticationPage()),
GetPage(name: RegistrationPageRoute, page: () => RegistrationPage()),
GetPage(name: ForgotPasswordPageRoute, page: () => ForgotPasswordPage()),
GetPage(name: InvitePageRoute + "/:inviteId/:userId", page: () => InvitePage()),
// GetPage(name: TrackPageRoute + "/:orderId", page: () => TrackPage())
],
debugShowCheckedModeBanner: false,
title: 'xyz.com',
theme: ThemeData(
hoverColor: Colors.transparent,
splashColor: Colors.transparent,
// highlightColor: Colors.transparent,
primarySwatch: Colors.blue,
scaffoldBackgroundColor: light,
// scaffoldBackgroundColor: Colors.white,
textTheme: GoogleFonts.mulishTextTheme(
Theme.of(context).textTheme).apply(
bodyColor: Colors.black
),
pageTransitionsTheme: PageTransitionsTheme(builders: {
TargetPlatform.iOS: FadeUpwardsPageTransitionsBuilder(),
TargetPlatform.android: FadeUpwardsPageTransitionsBuilder()
})
)
);
Thanks in advance. Feel free to ask anything.
Answer
Your code is absolutely OK and working without any issues. I tried but couldn't reproduce it.
However, you need to visit xyz.com/#/invite/dd/dd
instead of xyz.com/invite/dd/dd
.
Visiting xyz.com/invite/dd/dd
will redirect to the initial route.
To remove the #
from the URL, please refer to this
Related Questions
- → How do you create a 12 or 24 mnemonics code for multiple cryptocurrencies (ETH, BTC and so on..)
- → Flutter: input text field don't work properly in a simple example..... where am I wrong?
- → Can I customize the code formatting of Dart code in Atom?
- → Is it possible to develop iOS apps with Flutter on a Linux virtual machine?
- → Display SnackBar in Flutter
- → JSON ObjectMapper in Flutter
- → Material flutter app source code
- → TabBarSelection No such method error
- → How do I set the animation color of a LinearProgressIndicator?
- → Add different routes/screens to Flutter app
- → Is there a way to get the size of an existing widget?
- → How to share a file using flutter
- → Is there an easy way to find particular text built from RichText in a Flutter test?