Replies: 2 comments 6 replies
-
|
Hi, using See example app: https://github.com/jonataslaw/getx/blob/master/example_nav2/lib/app/middleware/auth_middleware.dart |
Beta Was this translation helpful? Give feedback.
4 replies
-
|
Use `Get.rootDelegate.toXXX()` for routing.
…On Sat, 6 Nov, 2021, 10:09 am Tony, ***@***.***> wrote:
Hey, as I mentioned you need to return GetMaterialApp.router() from your
MyApp.build()
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@OverRide
Widget build(BuildContext context) {
return GetMaterialApp.router(
// initialRoute: '/splashScreen',
getPages: [
GetPage(
name: '/splashScreen',
page: () => SplashScreen(),
binding: Bind(),
middlewares: [GlobalMiddleware()]),
GetPage(
name: '/login',
page: () => LoginPage(),
binding: Bind(),
),
GetPage(
name: '/mainPage', page: () => MainPage(), binding: Bind())
],
...
);
}
}
After change to GetMaterialApp.router(), it able to redirect to login
page. But when I press submit button in login page to go to main page,I get
another error.
Get.toNamed('/mainPage');
Reloaded 1 of 1342 libraries in 892ms.
E/flutter ( 7696): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: Navigator.onGenerateRoute was null, but the route named "/mainPage" was referenced.
E/flutter ( 7696): To use the Navigator API with named routes (pushNamed, pushReplacementNamed, or pushNamedAndRemoveUntil), the Navigator must be provided with an onGenerateRoute handler.
E/flutter ( 7696): The Navigator was:
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1566 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AACNO46ETE57HW64OGXHAKLUKSWQ3ANCNFSM47DTIHBQ>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
|
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi all, does anybody has used https://github.com/jonataslaw/getx#redirect redirect with async code?
For instance if authservice.isAuthenticated return a future like this:
class AuthMiddleware extends GetMiddleware {
@OverRide
RouteSettings? redirect(String? route) async {
final AuthenticationApi _authService = AuthenticationApi();
bool isUserAuthenticated = await _authService.isUserAuthenticated();
return RouteSettings(
name: isUserAuthenticated ? route : Navigation.login);
}
}
Beta Was this translation helpful? Give feedback.
All reactions