change getDelegate to rootDelegate, and make informationParser and routeDelegate…
… of GetX default on GetMaterialApp
Showing
11 changed files
with
115 additions
and
88 deletions
| @@ -28,33 +28,37 @@ class MyApp extends StatelessWidget { | @@ -28,33 +28,37 @@ class MyApp extends StatelessWidget { | ||
| 28 | } | 28 | } |
| 29 | } | 29 | } |
| 30 | 30 | ||
| 31 | -// Navigator 2 example, WIP | ||
| 32 | -// TODO: add all methods from NavigatorExtension to GetNav | 31 | +/// Nav 2 snippet |
| 32 | +// void main() { | ||
| 33 | +// runApp(MyApp()); | ||
| 34 | +// } | ||
| 33 | 35 | ||
| 34 | // class MyApp extends StatelessWidget { | 36 | // class MyApp extends StatelessWidget { |
| 35 | // MyApp({Key? key}) : super(key: key); | 37 | // MyApp({Key? key}) : super(key: key); |
| 36 | 38 | ||
| 37 | -// final getNav = Get.put( | ||
| 38 | -// GetNav(pages: [ | ||
| 39 | -// GetPage(name: '/first', page: () => First()), | ||
| 40 | -// GetPage(name: '/second', page: () => Second()), | ||
| 41 | -// GetPage(name: '/third', page: () => Third()), | ||
| 42 | -// ]), | ||
| 43 | -// ); | ||
| 44 | - | ||
| 45 | // @override | 39 | // @override |
| 46 | // Widget build(BuildContext context) { | 40 | // Widget build(BuildContext context) { |
| 47 | // return GetMaterialApp.router( | 41 | // return GetMaterialApp.router( |
| 42 | +// getPages: [ | ||
| 43 | +// GetPage( | ||
| 44 | +// participatesInRootNavigator: true, | ||
| 45 | +// name: '/first', | ||
| 46 | +// page: () => First()), | ||
| 47 | +// GetPage( | ||
| 48 | +// name: '/second', | ||
| 49 | +// page: () => Second(), | ||
| 50 | +// ), | ||
| 51 | +// GetPage( | ||
| 52 | +// name: '/third', | ||
| 53 | +// page: () => Third(), | ||
| 54 | +// ), | ||
| 55 | +// ], | ||
| 48 | // debugShowCheckedModeBanner: false, | 56 | // debugShowCheckedModeBanner: false, |
| 49 | -// routeInformationParser: getNav.routeInformationParser, | ||
| 50 | -// routerDelegate: getNav.routerDelegate, | ||
| 51 | // ); | 57 | // ); |
| 52 | // } | 58 | // } |
| 53 | // } | 59 | // } |
| 54 | 60 | ||
| 55 | // class First extends StatelessWidget { | 61 | // class First extends StatelessWidget { |
| 56 | -// final GetNav getNav = Get.find(); | ||
| 57 | - | ||
| 58 | // @override | 62 | // @override |
| 59 | // Widget build(BuildContext context) { | 63 | // Widget build(BuildContext context) { |
| 60 | // return Scaffold( | 64 | // return Scaffold( |
| @@ -73,9 +77,7 @@ class MyApp extends StatelessWidget { | @@ -73,9 +77,7 @@ class MyApp extends StatelessWidget { | ||
| 73 | // height: 300, | 77 | // height: 300, |
| 74 | // width: 300, | 78 | // width: 300, |
| 75 | // child: ElevatedButton( | 79 | // child: ElevatedButton( |
| 76 | -// onPressed: () { | ||
| 77 | -// getNav.toNamed('/second?id=584305'); | ||
| 78 | -// }, | 80 | +// onPressed: () {}, |
| 79 | // child: Text('next screen'), | 81 | // child: Text('next screen'), |
| 80 | // ), | 82 | // ), |
| 81 | // ), | 83 | // ), |
| @@ -85,7 +87,6 @@ class MyApp extends StatelessWidget { | @@ -85,7 +87,6 @@ class MyApp extends StatelessWidget { | ||
| 85 | // } | 87 | // } |
| 86 | 88 | ||
| 87 | // class Second extends StatelessWidget { | 89 | // class Second extends StatelessWidget { |
| 88 | -// final GetNav getNav = Get.find(); | ||
| 89 | // @override | 90 | // @override |
| 90 | // Widget build(BuildContext context) { | 91 | // Widget build(BuildContext context) { |
| 91 | // return Scaffold( | 92 | // return Scaffold( |
| @@ -97,9 +98,7 @@ class MyApp extends StatelessWidget { | @@ -97,9 +98,7 @@ class MyApp extends StatelessWidget { | ||
| 97 | // height: 300, | 98 | // height: 300, |
| 98 | // width: 300, | 99 | // width: 300, |
| 99 | // child: ElevatedButton( | 100 | // child: ElevatedButton( |
| 100 | -// onPressed: () { | ||
| 101 | -// getNav.toNamed('/third'); | ||
| 102 | -// }, | 101 | +// onPressed: () {}, |
| 103 | // child: Text('next screen'), | 102 | // child: Text('next screen'), |
| 104 | // ), | 103 | // ), |
| 105 | // ), | 104 | // ), |
| @@ -109,7 +108,6 @@ class MyApp extends StatelessWidget { | @@ -109,7 +108,6 @@ class MyApp extends StatelessWidget { | ||
| 109 | // } | 108 | // } |
| 110 | 109 | ||
| 111 | // class Third extends StatelessWidget { | 110 | // class Third extends StatelessWidget { |
| 112 | -// final GetNav getNav = Get.find(); | ||
| 113 | // @override | 111 | // @override |
| 114 | // Widget build(BuildContext context) { | 112 | // Widget build(BuildContext context) { |
| 115 | // return Scaffold( | 113 | // return Scaffold( |
| @@ -122,9 +120,7 @@ class MyApp extends StatelessWidget { | @@ -122,9 +120,7 @@ class MyApp extends StatelessWidget { | ||
| 122 | // height: 300, | 120 | // height: 300, |
| 123 | // width: 300, | 121 | // width: 300, |
| 124 | // child: ElevatedButton( | 122 | // child: ElevatedButton( |
| 125 | -// onPressed: () { | ||
| 126 | -// getNav.offUntil('/first'); | ||
| 127 | -// }, | 123 | +// onPressed: () {}, |
| 128 | // child: Text('go to first screen'), | 124 | // child: Text('go to first screen'), |
| 129 | // ), | 125 | // ), |
| 130 | // ), | 126 | // ), |
| 1 | -import 'package:example_nav2/app/routes/app_pages.dart'; | ||
| 2 | -import 'package:example_nav2/services/auth_service.dart'; | ||
| 3 | import 'package:flutter/material.dart'; | 1 | import 'package:flutter/material.dart'; |
| 4 | - | ||
| 5 | import 'package:get/get.dart'; | 2 | import 'package:get/get.dart'; |
| 6 | 3 | ||
| 4 | +import '../../../../services/auth_service.dart'; | ||
| 5 | +import '../../../routes/app_pages.dart'; | ||
| 7 | import '../controllers/login_controller.dart'; | 6 | import '../controllers/login_controller.dart'; |
| 8 | 7 | ||
| 9 | class LoginView extends GetView<LoginController> { | 8 | class LoginView extends GetView<LoginController> { |
| @@ -32,11 +31,9 @@ class LoginView extends GetView<LoginController> { | @@ -32,11 +31,9 @@ class LoginView extends GetView<LoginController> { | ||
| 32 | ), | 31 | ), |
| 33 | onPressed: () { | 32 | onPressed: () { |
| 34 | AuthService.to.login(); | 33 | AuthService.to.login(); |
| 35 | - final thenTo = Get.getDelegate()! | ||
| 36 | - .currentConfiguration! | ||
| 37 | - .currentPage! | ||
| 38 | - .parameter?['then']; | ||
| 39 | - Get.getDelegate()!.toNamed(thenTo ?? Routes.HOME); | 34 | + final thenTo = Get.rootDelegate.currentConfiguration! |
| 35 | + .currentPage!.parameter?['then']; | ||
| 36 | + Get.rootDelegate.toNamed(thenTo ?? Routes.HOME); | ||
| 40 | }, | 37 | }, |
| 41 | ), | 38 | ), |
| 42 | ], | 39 | ], |
| 1 | -import 'package:example_nav2/models/demo_product.dart'; | ||
| 2 | import 'package:get/get.dart'; | 1 | import 'package:get/get.dart'; |
| 3 | 2 | ||
| 3 | +import '../../../../models/demo_product.dart'; | ||
| 4 | + | ||
| 4 | class ProductsController extends GetxController { | 5 | class ProductsController extends GetxController { |
| 5 | final products = <DemoProduct>[].obs; | 6 | final products = <DemoProduct>[].obs; |
| 6 | 7 |
| @@ -24,7 +24,7 @@ class ProductsView extends GetView<ProductsController> { | @@ -24,7 +24,7 @@ class ProductsView extends GetView<ProductsController> { | ||
| 24 | final item = controller.products[index]; | 24 | final item = controller.products[index]; |
| 25 | return ListTile( | 25 | return ListTile( |
| 26 | onTap: () { | 26 | onTap: () { |
| 27 | - Get.getDelegate()?.toNamed(Routes.PRODUCT_DETAILS(item.id)); | 27 | + Get.rootDelegate.toNamed(Routes.PRODUCT_DETAILS(item.id)); |
| 28 | }, | 28 | }, |
| 29 | title: Text(item.name), | 29 | title: Text(item.name), |
| 30 | subtitle: Text(item.id), | 30 | subtitle: Text(item.id), |
| @@ -21,7 +21,7 @@ class DrawerWidget extends StatelessWidget { | @@ -21,7 +21,7 @@ class DrawerWidget extends StatelessWidget { | ||
| 21 | ListTile( | 21 | ListTile( |
| 22 | title: Text('Home'), | 22 | title: Text('Home'), |
| 23 | onTap: () { | 23 | onTap: () { |
| 24 | - Get.getDelegate()?.toNamed(Routes.HOME); | 24 | + Get.rootDelegate.toNamed(Routes.HOME); |
| 25 | //to close the drawer | 25 | //to close the drawer |
| 26 | 26 | ||
| 27 | Navigator.of(context).pop(); | 27 | Navigator.of(context).pop(); |
| @@ -30,7 +30,7 @@ class DrawerWidget extends StatelessWidget { | @@ -30,7 +30,7 @@ class DrawerWidget extends StatelessWidget { | ||
| 30 | ListTile( | 30 | ListTile( |
| 31 | title: Text('Settings'), | 31 | title: Text('Settings'), |
| 32 | onTap: () { | 32 | onTap: () { |
| 33 | - Get.getDelegate()?.toNamed(Routes.SETTINGS); | 33 | + Get.rootDelegate.toNamed(Routes.SETTINGS); |
| 34 | //to close the drawer | 34 | //to close the drawer |
| 35 | 35 | ||
| 36 | Navigator.of(context).pop(); | 36 | Navigator.of(context).pop(); |
| @@ -46,7 +46,7 @@ class DrawerWidget extends StatelessWidget { | @@ -46,7 +46,7 @@ class DrawerWidget extends StatelessWidget { | ||
| 46 | ), | 46 | ), |
| 47 | onTap: () { | 47 | onTap: () { |
| 48 | AuthService.to.logout(); | 48 | AuthService.to.logout(); |
| 49 | - Get.getDelegate()!.toNamed(Routes.LOGIN); | 49 | + Get.rootDelegate.toNamed(Routes.LOGIN); |
| 50 | //to close the drawer | 50 | //to close the drawer |
| 51 | 51 | ||
| 52 | Navigator.of(context).pop(); | 52 | Navigator.of(context).pop(); |
| @@ -61,7 +61,7 @@ class DrawerWidget extends StatelessWidget { | @@ -61,7 +61,7 @@ class DrawerWidget extends StatelessWidget { | ||
| 61 | ), | 61 | ), |
| 62 | ), | 62 | ), |
| 63 | onTap: () { | 63 | onTap: () { |
| 64 | - Get.getDelegate()!.toNamed(Routes.LOGIN); | 64 | + Get.rootDelegate.toNamed(Routes.LOGIN); |
| 65 | //to close the drawer | 65 | //to close the drawer |
| 66 | 66 | ||
| 67 | Navigator.of(context).pop(); | 67 | Navigator.of(context).pop(); |
| @@ -948,23 +948,6 @@ you can only use widgets and widget functions here'''; | @@ -948,23 +948,6 @@ you can only use widgets and widget functions here'''; | ||
| 948 | predicate ?? (route) => false); | 948 | predicate ?? (route) => false); |
| 949 | } | 949 | } |
| 950 | 950 | ||
| 951 | - void registerRoutes(List<GetPage> getPages) { | ||
| 952 | - //TODO: only replace if null??? | ||
| 953 | - routeTree = ParseRouteTree(routes: <GetPage>[]); | ||
| 954 | - routeTree.addRoutes(getPages); | ||
| 955 | - } | ||
| 956 | - | ||
| 957 | - void addPages(List<GetPage>? getPages) { | ||
| 958 | - if (getPages != null) { | ||
| 959 | - registerRoutes(getPages); | ||
| 960 | - } | ||
| 961 | - } | ||
| 962 | - | ||
| 963 | - void addPage(GetPage getPage) { | ||
| 964 | - // routeTree = ParseRouteTree(); | ||
| 965 | - routeTree.addRoute(getPage); | ||
| 966 | - } | ||
| 967 | - | ||
| 968 | /// change default config of Get | 951 | /// change default config of Get |
| 969 | void config( | 952 | void config( |
| 970 | {bool? enableLog, | 953 | {bool? enableLog, |
| @@ -1061,19 +1044,6 @@ you can only use widgets and widget functions here'''; | @@ -1061,19 +1044,6 @@ you can only use widgets and widget functions here'''; | ||
| 1061 | return _key; | 1044 | return _key; |
| 1062 | } | 1045 | } |
| 1063 | 1046 | ||
| 1064 | - /// Casts the stored router delegate to a desired type | ||
| 1065 | - TDelegate? delegate<TDelegate extends RouterDelegate<TPage>, TPage>() => | ||
| 1066 | - _routerDelegate as TDelegate?; | ||
| 1067 | - | ||
| 1068 | - static RouterDelegate? _routerDelegate; | ||
| 1069 | - | ||
| 1070 | - // ignore: use_setters_to_change_properties | ||
| 1071 | - void setDefaultDelegate(RouterDelegate? delegate) { | ||
| 1072 | - _routerDelegate = delegate; | ||
| 1073 | - } | ||
| 1074 | - | ||
| 1075 | - GetDelegate? getDelegate() => delegate<GetDelegate, GetNavConfig>(); | ||
| 1076 | - | ||
| 1077 | /// give current arguments | 1047 | /// give current arguments |
| 1078 | dynamic get arguments => routing.args; | 1048 | dynamic get arguments => routing.args; |
| 1079 | 1049 | ||
| @@ -1213,9 +1183,6 @@ you can only use widgets and widget functions here'''; | @@ -1213,9 +1183,6 @@ you can only use widgets and widget functions here'''; | ||
| 1213 | set parameters(Map<String, String?> newParameters) => | 1183 | set parameters(Map<String, String?> newParameters) => |
| 1214 | getxController.parameters = newParameters; | 1184 | getxController.parameters = newParameters; |
| 1215 | 1185 | ||
| 1216 | - ParseRouteTree get routeTree => getxController.routeTree; | ||
| 1217 | - set routeTree(ParseRouteTree tree) => getxController.routeTree = tree; | ||
| 1218 | - | ||
| 1219 | CustomTransition? get customTransition => getxController.customTransition; | 1186 | CustomTransition? get customTransition => getxController.customTransition; |
| 1220 | set customTransition(CustomTransition? newTransition) => | 1187 | set customTransition(CustomTransition? newTransition) => |
| 1221 | getxController.customTransition = newTransition; | 1188 | getxController.customTransition = newTransition; |
| @@ -1226,6 +1193,59 @@ you can only use widgets and widget functions here'''; | @@ -1226,6 +1193,59 @@ you can only use widgets and widget functions here'''; | ||
| 1226 | static GetMaterialController getxController = GetMaterialController(); | 1193 | static GetMaterialController getxController = GetMaterialController(); |
| 1227 | } | 1194 | } |
| 1228 | 1195 | ||
| 1196 | +extension NavTwoExt on GetInterface { | ||
| 1197 | + void addPages(List<GetPage> getPages) { | ||
| 1198 | + routeTree.addRoutes(getPages); | ||
| 1199 | + } | ||
| 1200 | + | ||
| 1201 | + static late final _routeTree = ParseRouteTree(routes: []); | ||
| 1202 | + | ||
| 1203 | + ParseRouteTree get routeTree => _routeTree; | ||
| 1204 | + void addPage(GetPage getPage) { | ||
| 1205 | + routeTree.addRoute(getPage); | ||
| 1206 | + } | ||
| 1207 | + | ||
| 1208 | + /// Casts the stored router delegate to a desired type | ||
| 1209 | + TDelegate? delegate<TDelegate extends RouterDelegate<TPage>, TPage>() => | ||
| 1210 | + _routerDelegate as TDelegate?; | ||
| 1211 | + | ||
| 1212 | + static GetDelegate? _routerDelegate; | ||
| 1213 | + | ||
| 1214 | + // // ignore: use_setters_to_change_properties | ||
| 1215 | + // void setDefaultDelegate(RouterDelegate? delegate) { | ||
| 1216 | + // _routerDelegate = delegate; | ||
| 1217 | + // } | ||
| 1218 | + | ||
| 1219 | + // GetDelegate? getDelegate() => delegate<GetDelegate, GetNavConfig>(); | ||
| 1220 | + | ||
| 1221 | + static GetInformationParser? _informationParser; | ||
| 1222 | + | ||
| 1223 | + GetInformationParser createInformationParser({String initialRoute = '/'}) { | ||
| 1224 | + return _informationParser ??= | ||
| 1225 | + GetInformationParser(initialRoute: initialRoute); | ||
| 1226 | + } | ||
| 1227 | + | ||
| 1228 | + // static GetDelegate? _delegate; | ||
| 1229 | + | ||
| 1230 | + GetDelegate get rootDelegate => createDelegate(); | ||
| 1231 | + | ||
| 1232 | + GetDelegate createDelegate( | ||
| 1233 | + {GetPage<dynamic>? notFoundRoute, | ||
| 1234 | + List<NavigatorObserver>? navigatorObservers, | ||
| 1235 | + TransitionDelegate<dynamic>? transitionDelegate, | ||
| 1236 | + PopMode backButtonPopMode = PopMode.History, | ||
| 1237 | + PreventDuplicateHandlingMode preventDuplicateHandlingMode = | ||
| 1238 | + PreventDuplicateHandlingMode.ReorderRoutes}) { | ||
| 1239 | + return _routerDelegate ??= GetDelegate( | ||
| 1240 | + notFoundRoute: notFoundRoute, | ||
| 1241 | + navigatorObservers: navigatorObservers, | ||
| 1242 | + transitionDelegate: transitionDelegate, | ||
| 1243 | + backButtonPopMode: backButtonPopMode, | ||
| 1244 | + preventDuplicateHandlingMode: preventDuplicateHandlingMode, | ||
| 1245 | + ); | ||
| 1246 | + } | ||
| 1247 | +} | ||
| 1248 | + | ||
| 1229 | /// It replaces the Flutter Navigator, but needs no context. | 1249 | /// It replaces the Flutter Navigator, but needs no context. |
| 1230 | /// You can to use navigator.push(YourRoute()) rather | 1250 | /// You can to use navigator.push(YourRoute()) rather |
| 1231 | /// Navigator.push(context, YourRoute()); | 1251 | /// Navigator.push(context, YourRoute()); |
| @@ -46,7 +46,7 @@ enum PreventDuplicateHandlingMode { | @@ -46,7 +46,7 @@ enum PreventDuplicateHandlingMode { | ||
| 46 | ReorderRoutes | 46 | ReorderRoutes |
| 47 | } | 47 | } |
| 48 | 48 | ||
| 49 | -class GetDelegate extends RouterDelegate<GetNavConfig> | 49 | +class GetDelegate<T> extends RouterDelegate<GetNavConfig> |
| 50 | with ListenableMixin, ListNotifierMixin { | 50 | with ListenableMixin, ListNotifierMixin { |
| 51 | final List<GetNavConfig> history = <GetNavConfig>[]; | 51 | final List<GetNavConfig> history = <GetNavConfig>[]; |
| 52 | final PopMode backButtonPopMode; | 52 | final PopMode backButtonPopMode; |
| @@ -116,7 +116,7 @@ class GetRouterOutlet extends RouterOutlet<GetDelegate, GetNavConfig> { | @@ -116,7 +116,7 @@ class GetRouterOutlet extends RouterOutlet<GetDelegate, GetNavConfig> { | ||
| 116 | return (emptyWidget?.call(rDelegate) ?? SizedBox.shrink()); | 116 | return (emptyWidget?.call(rDelegate) ?? SizedBox.shrink()); |
| 117 | }, | 117 | }, |
| 118 | pickPages: pickPages, | 118 | pickPages: pickPages, |
| 119 | - delegate: Get.getDelegate(), | 119 | + delegate: Get.rootDelegate, |
| 120 | ); | 120 | ); |
| 121 | } | 121 | } |
| 122 | 122 |
| @@ -118,12 +118,12 @@ class GetCupertinoApp extends StatelessWidget { | @@ -118,12 +118,12 @@ class GetCupertinoApp extends StatelessWidget { | ||
| 118 | final BackButtonDispatcher? backButtonDispatcher; | 118 | final BackButtonDispatcher? backButtonDispatcher; |
| 119 | final CupertinoThemeData? theme; | 119 | final CupertinoThemeData? theme; |
| 120 | 120 | ||
| 121 | - const GetCupertinoApp.router({ | 121 | + GetCupertinoApp.router({ |
| 122 | Key? key, | 122 | Key? key, |
| 123 | this.theme, | 123 | this.theme, |
| 124 | this.routeInformationProvider, | 124 | this.routeInformationProvider, |
| 125 | - required RouteInformationParser<Object> this.routeInformationParser, | ||
| 126 | - required RouterDelegate<Object> this.routerDelegate, | 125 | + RouteInformationParser<Object>? routeInformationParser, |
| 126 | + RouterDelegate<Object>? routerDelegate, | ||
| 127 | this.backButtonDispatcher, | 127 | this.backButtonDispatcher, |
| 128 | this.builder, | 128 | this.builder, |
| 129 | this.title = '', | 129 | this.title = '', |
| @@ -163,7 +163,12 @@ class GetCupertinoApp extends StatelessWidget { | @@ -163,7 +163,12 @@ class GetCupertinoApp extends StatelessWidget { | ||
| 163 | this.defaultGlobalState, | 163 | this.defaultGlobalState, |
| 164 | this.getPages, | 164 | this.getPages, |
| 165 | this.unknownRoute, | 165 | this.unknownRoute, |
| 166 | - }) : navigatorObservers = null, | 166 | + }) : routerDelegate = routerDelegate ?? Get.createDelegate(), |
| 167 | + routeInformationParser = routeInformationParser ?? | ||
| 168 | + Get.createInformationParser( | ||
| 169 | + initialRoute: getPages?.first.name ?? '/', | ||
| 170 | + ), | ||
| 171 | + navigatorObservers = null, | ||
| 167 | navigatorKey = null, | 172 | navigatorKey = null, |
| 168 | onGenerateRoute = null, | 173 | onGenerateRoute = null, |
| 169 | home = null, | 174 | home = null, |
| @@ -209,7 +214,10 @@ class GetCupertinoApp extends StatelessWidget { | @@ -209,7 +214,10 @@ class GetCupertinoApp extends StatelessWidget { | ||
| 209 | Get.customTransition = customTransition; | 214 | Get.customTransition = customTransition; |
| 210 | 215 | ||
| 211 | initialBinding?.dependencies(); | 216 | initialBinding?.dependencies(); |
| 212 | - Get.addPages(getPages); | 217 | + if (getPages != null) { |
| 218 | + Get.addPages(getPages!); | ||
| 219 | + } | ||
| 220 | + | ||
| 213 | Get.smartManagement = smartManagement; | 221 | Get.smartManagement = smartManagement; |
| 214 | onInit?.call(); | 222 | onInit?.call(); |
| 215 | 223 |
| @@ -125,11 +125,11 @@ class GetMaterialApp extends StatelessWidget { | @@ -125,11 +125,11 @@ class GetMaterialApp extends StatelessWidget { | ||
| 125 | final RouterDelegate<Object>? routerDelegate; | 125 | final RouterDelegate<Object>? routerDelegate; |
| 126 | final BackButtonDispatcher? backButtonDispatcher; | 126 | final BackButtonDispatcher? backButtonDispatcher; |
| 127 | 127 | ||
| 128 | - const GetMaterialApp.router({ | 128 | + GetMaterialApp.router({ |
| 129 | Key? key, | 129 | Key? key, |
| 130 | this.routeInformationProvider, | 130 | this.routeInformationProvider, |
| 131 | - required RouteInformationParser<Object> this.routeInformationParser, | ||
| 132 | - required RouterDelegate<Object> this.routerDelegate, | 131 | + RouteInformationParser<Object>? routeInformationParser, |
| 132 | + RouterDelegate<Object>? routerDelegate, | ||
| 133 | this.backButtonDispatcher, | 133 | this.backButtonDispatcher, |
| 134 | this.builder, | 134 | this.builder, |
| 135 | this.title = '', | 135 | this.title = '', |
| @@ -173,7 +173,12 @@ class GetMaterialApp extends StatelessWidget { | @@ -173,7 +173,12 @@ class GetMaterialApp extends StatelessWidget { | ||
| 173 | this.defaultGlobalState, | 173 | this.defaultGlobalState, |
| 174 | this.getPages, | 174 | this.getPages, |
| 175 | this.unknownRoute, | 175 | this.unknownRoute, |
| 176 | - }) : navigatorObservers = null, | 176 | + }) : routerDelegate = routerDelegate ?? Get.createDelegate(), |
| 177 | + routeInformationParser = routeInformationParser ?? | ||
| 178 | + Get.createInformationParser( | ||
| 179 | + initialRoute: getPages?.first.name ?? '/', | ||
| 180 | + ), | ||
| 181 | + navigatorObservers = null, | ||
| 177 | navigatorKey = null, | 182 | navigatorKey = null, |
| 178 | onGenerateRoute = null, | 183 | onGenerateRoute = null, |
| 179 | home = null, | 184 | home = null, |
| @@ -219,8 +224,11 @@ class GetMaterialApp extends StatelessWidget { | @@ -219,8 +224,11 @@ class GetMaterialApp extends StatelessWidget { | ||
| 219 | Get.customTransition = customTransition; | 224 | Get.customTransition = customTransition; |
| 220 | 225 | ||
| 221 | initialBinding?.dependencies(); | 226 | initialBinding?.dependencies(); |
| 222 | - Get.addPages(getPages); | ||
| 223 | - Get.setDefaultDelegate(routerDelegate); | 227 | + if (getPages != null) { |
| 228 | + Get.addPages(getPages!); | ||
| 229 | + } | ||
| 230 | + | ||
| 231 | + //Get.setDefaultDelegate(routerDelegate); | ||
| 224 | Get.smartManagement = smartManagement; | 232 | Get.smartManagement = smartManagement; |
| 225 | onInit?.call(); | 233 | onInit?.call(); |
| 226 | 234 |
| @@ -4,7 +4,6 @@ import '../../../get_utils/get_utils.dart'; | @@ -4,7 +4,6 @@ import '../../../get_utils/get_utils.dart'; | ||
| 4 | import '../routes/custom_transition.dart'; | 4 | import '../routes/custom_transition.dart'; |
| 5 | import '../routes/observers/route_observer.dart'; | 5 | import '../routes/observers/route_observer.dart'; |
| 6 | import '../routes/transitions_type.dart'; | 6 | import '../routes/transitions_type.dart'; |
| 7 | -import 'parse_route.dart'; | ||
| 8 | 7 | ||
| 9 | class GetMaterialController extends GetxController { | 8 | class GetMaterialController extends GetxController { |
| 10 | bool testMode = false; | 9 | bool testMode = false; |
| @@ -28,8 +27,6 @@ class GetMaterialController extends GetxController { | @@ -28,8 +27,6 @@ class GetMaterialController extends GetxController { | ||
| 28 | 27 | ||
| 29 | Map<String, String?> parameters = {}; | 28 | Map<String, String?> parameters = {}; |
| 30 | 29 | ||
| 31 | - late ParseRouteTree routeTree; | ||
| 32 | - | ||
| 33 | CustomTransition? customTransition; | 30 | CustomTransition? customTransition; |
| 34 | 31 | ||
| 35 | GlobalKey<NavigatorState> key = GlobalKey<NavigatorState>(); | 32 | GlobalKey<NavigatorState> key = GlobalKey<NavigatorState>(); |
-
Please register or login to post a comment