Showing
37 changed files
with
485 additions
and
588 deletions
@@ -5,13 +5,11 @@ import '../data/home_repository.dart'; | @@ -5,13 +5,11 @@ import '../data/home_repository.dart'; | ||
5 | import '../domain/adapters/repository_adapter.dart'; | 5 | import '../domain/adapters/repository_adapter.dart'; |
6 | import '../presentation/controllers/home_controller.dart'; | 6 | import '../presentation/controllers/home_controller.dart'; |
7 | 7 | ||
8 | -class HomeBinding extends Binding { | 8 | +class HomeBinding extends Bindings { |
9 | @override | 9 | @override |
10 | - List<Bind> dependencies() { | ||
11 | - return [ | ||
12 | - Bind.lazyPut<IHomeProvider>(() => HomeProvider()), | ||
13 | - Bind.lazyPut<IHomeRepository>(() => HomeRepository(provider: Get.find())), | ||
14 | - Bind.lazyPut(() => HomeController(homeRepository: Get.find())), | ||
15 | - ]; | 10 | + void dependencies() { |
11 | + Get.lazyPut<IHomeProvider>(() => HomeProvider()); | ||
12 | + Get.lazyPut<IHomeRepository>(() => HomeRepository(provider: Get.find())); | ||
13 | + Get.lazyPut(() => HomeController(homeRepository: Get.find())); | ||
16 | } | 14 | } |
17 | } | 15 | } |
@@ -9,8 +9,6 @@ class CountryView extends GetView<HomeController> { | @@ -9,8 +9,6 @@ class CountryView extends GetView<HomeController> { | ||
9 | const CountryView({Key? key}) : super(key: key); | 9 | const CountryView({Key? key}) : super(key: key); |
10 | @override | 10 | @override |
11 | Widget build(BuildContext context) { | 11 | Widget build(BuildContext context) { |
12 | - print('BUILD CONTRY'); | ||
13 | - print(context.params); | ||
14 | return Container( | 12 | return Container( |
15 | decoration: BoxDecoration( | 13 | decoration: BoxDecoration( |
16 | image: DecorationImage( | 14 | image: DecorationImage( |
@@ -9,8 +9,7 @@ class DetailsView extends GetView<HomeController> { | @@ -9,8 +9,7 @@ class DetailsView extends GetView<HomeController> { | ||
9 | const DetailsView({Key? key}) : super(key: key); | 9 | const DetailsView({Key? key}) : super(key: key); |
10 | @override | 10 | @override |
11 | Widget build(BuildContext context) { | 11 | Widget build(BuildContext context) { |
12 | - final args = ModalRoute.of(context)!.settings.arguments as PageSettings; | ||
13 | - final parameter = args.params; //Get.rootDelegate.parameters; | 12 | + final parameter = context.params; //Get.parameters; |
14 | final country = controller.getCountryById(parameter['id'] ?? ''); | 13 | final country = controller.getCountryById(parameter['id'] ?? ''); |
15 | return Container( | 14 | return Container( |
16 | decoration: BoxDecoration( | 15 | decoration: BoxDecoration( |
@@ -8,8 +8,6 @@ class HomeView extends GetView<HomeController> { | @@ -8,8 +8,6 @@ class HomeView extends GetView<HomeController> { | ||
8 | 8 | ||
9 | @override | 9 | @override |
10 | Widget build(BuildContext context) { | 10 | Widget build(BuildContext context) { |
11 | - print('REBUILD HOME'); | ||
12 | - // print(Get.parameters); | ||
13 | return Container( | 11 | return Container( |
14 | decoration: BoxDecoration( | 12 | decoration: BoxDecoration( |
15 | color: Colors.white, | 13 | color: Colors.white, |
@@ -80,7 +78,7 @@ class HomeView extends GetView<HomeController> { | @@ -80,7 +78,7 @@ class HomeView extends GetView<HomeController> { | ||
80 | ), | 78 | ), |
81 | onPressed: () async { | 79 | onPressed: () async { |
82 | //await Navigation Get.rootDelegate.toNamed('/home/country'); | 80 | //await Navigation Get.rootDelegate.toNamed('/home/country'); |
83 | - Get.toNamed('/countrdhia'); | 81 | + Get.toNamed('/home/country'); |
84 | }, | 82 | }, |
85 | child: Text( | 83 | child: Text( |
86 | 'fetch_country'.tr, | 84 | 'fetch_country'.tr, |
@@ -2,30 +2,32 @@ import 'package:get/get.dart'; | @@ -2,30 +2,32 @@ import 'package:get/get.dart'; | ||
2 | 2 | ||
3 | import '../pages/home/bindings/home_binding.dart'; | 3 | import '../pages/home/bindings/home_binding.dart'; |
4 | import '../pages/home/presentation/views/country_view.dart'; | 4 | import '../pages/home/presentation/views/country_view.dart'; |
5 | +import '../pages/home/presentation/views/details_view.dart'; | ||
5 | import '../pages/home/presentation/views/home_view.dart'; | 6 | import '../pages/home/presentation/views/home_view.dart'; |
6 | 7 | ||
7 | part 'app_routes.dart'; | 8 | part 'app_routes.dart'; |
8 | 9 | ||
9 | // ignore: avoid_classes_with_only_static_members | 10 | // ignore: avoid_classes_with_only_static_members |
10 | class AppPages { | 11 | class AppPages { |
11 | - static const INITIAL = '${Routes.HOME}?schineider=uuu'; | 12 | + static const INITIAL = Routes.HOME; |
12 | 13 | ||
13 | static final routes = [ | 14 | static final routes = [ |
14 | GetPage( | 15 | GetPage( |
15 | - name: '${Routes.HOME}', | ||
16 | - page: () => const HomeView(), | ||
17 | - binding: HomeBinding(), | ||
18 | - children: [], | ||
19 | - ), | 16 | + name: Routes.HOME, |
17 | + page: () => HomeView(), | ||
18 | + bindings: [HomeBinding()], | ||
19 | + children: [ | ||
20 | + GetPage( | ||
21 | + name: Routes.COUNTRY, | ||
22 | + page: () => CountryView(), | ||
23 | + children: [ | ||
20 | GetPage( | 24 | GetPage( |
21 | - name: '${Routes.COUNTRY}/:xasa', | ||
22 | - page: () => const CountryView(), | ||
23 | - // children: [ | ||
24 | - // GetPage( | ||
25 | - // name: Routes.DETAILS, | ||
26 | - // page: () => DetailsView(), | ||
27 | - // ), | ||
28 | - // ], | 25 | + name: Routes.DETAILS, |
26 | + page: () => DetailsView(), | ||
27 | + ), | ||
28 | + ], | ||
29 | + ), | ||
30 | + ], | ||
29 | ), | 31 | ), |
30 | ]; | 32 | ]; |
31 | } | 33 | } |
@@ -5,23 +5,24 @@ import '../routes/app_pages.dart'; | @@ -5,23 +5,24 @@ import '../routes/app_pages.dart'; | ||
5 | 5 | ||
6 | class EnsureAuthMiddleware extends GetMiddleware { | 6 | class EnsureAuthMiddleware extends GetMiddleware { |
7 | @override | 7 | @override |
8 | - Future<RouteDecoder?> redirectDelegate(RouteDecoder route) async { | 8 | + Future<RouteDecoder?> redirect(RouteDecoder route) async { |
9 | // you can do whatever you want here | 9 | // you can do whatever you want here |
10 | // but it's preferable to make this method fast | 10 | // but it's preferable to make this method fast |
11 | // await Future.delayed(Duration(milliseconds: 500)); | 11 | // await Future.delayed(Duration(milliseconds: 500)); |
12 | 12 | ||
13 | if (!AuthService.to.isLoggedInValue) { | 13 | if (!AuthService.to.isLoggedInValue) { |
14 | - final newRoute = Routes.LOGIN_THEN(route.arguments!.name); | 14 | + final path = route.args.name as String; |
15 | + final newRoute = Routes.LOGIN_THEN(path); | ||
15 | 16 | ||
16 | return RouteDecoder.fromRoute(newRoute); | 17 | return RouteDecoder.fromRoute(newRoute); |
17 | } | 18 | } |
18 | - return await super.redirectDelegate(route); | 19 | + return await super.redirect(route); |
19 | } | 20 | } |
20 | } | 21 | } |
21 | 22 | ||
22 | class EnsureNotAuthedMiddleware extends GetMiddleware { | 23 | class EnsureNotAuthedMiddleware extends GetMiddleware { |
23 | @override | 24 | @override |
24 | - Future<RouteDecoder?> redirectDelegate(RouteDecoder route) async { | 25 | + Future<RouteDecoder?> redirect(RouteDecoder route) async { |
25 | if (AuthService.to.isLoggedInValue) { | 26 | if (AuthService.to.isLoggedInValue) { |
26 | //NEVER navigate to auth screen, when user is already authed | 27 | //NEVER navigate to auth screen, when user is already authed |
27 | return null; | 28 | return null; |
@@ -29,6 +30,6 @@ class EnsureNotAuthedMiddleware extends GetMiddleware { | @@ -29,6 +30,6 @@ class EnsureNotAuthedMiddleware extends GetMiddleware { | ||
29 | //OR redirect user to another screen | 30 | //OR redirect user to another screen |
30 | //return RouteDecoder.fromRoute(Routes.PROFILE); | 31 | //return RouteDecoder.fromRoute(Routes.PROFILE); |
31 | } | 32 | } |
32 | - return await super.redirectDelegate(route); | 33 | + return await super.redirect(route); |
33 | } | 34 | } |
34 | } | 35 | } |
@@ -31,8 +31,7 @@ class ProductsView extends GetView<ProductsController> { | @@ -31,8 +31,7 @@ class ProductsView extends GetView<ProductsController> { | ||
31 | final item = controller.products[index]; | 31 | final item = controller.products[index]; |
32 | return ListTile( | 32 | return ListTile( |
33 | onTap: () { | 33 | onTap: () { |
34 | - Get | ||
35 | - .toNamed(Routes.PRODUCT_DETAILS(item.id)); | 34 | + Get.toNamed(Routes.PRODUCT_DETAILS(item.id)); |
36 | }, | 35 | }, |
37 | title: Text(item.name), | 36 | title: Text(item.name), |
38 | subtitle: Text(item.id), | 37 | subtitle: Text(item.id), |
@@ -29,7 +29,7 @@ class AppPages { | @@ -29,7 +29,7 @@ class AppPages { | ||
29 | GetPage( | 29 | GetPage( |
30 | name: '/', | 30 | name: '/', |
31 | page: () => RootView(), | 31 | page: () => RootView(), |
32 | - binding: RootBinding(), | 32 | + bindings: [RootBinding()], |
33 | participatesInRootNavigator: true, | 33 | participatesInRootNavigator: true, |
34 | preventDuplicates: true, | 34 | preventDuplicates: true, |
35 | children: [ | 35 | children: [ |
@@ -40,19 +40,23 @@ class AppPages { | @@ -40,19 +40,23 @@ class AppPages { | ||
40 | ], | 40 | ], |
41 | name: _Paths.LOGIN, | 41 | name: _Paths.LOGIN, |
42 | page: () => LoginView(), | 42 | page: () => LoginView(), |
43 | - binding: LoginBinding(), | 43 | + bindings: [LoginBinding()], |
44 | ), | 44 | ), |
45 | GetPage( | 45 | GetPage( |
46 | preventDuplicates: true, | 46 | preventDuplicates: true, |
47 | name: _Paths.HOME, | 47 | name: _Paths.HOME, |
48 | page: () => HomeView(), | 48 | page: () => HomeView(), |
49 | - binding: HomeBinding(), | 49 | + bindings: [ |
50 | + HomeBinding(), | ||
51 | + ], | ||
50 | title: null, | 52 | title: null, |
51 | children: [ | 53 | children: [ |
52 | GetPage( | 54 | GetPage( |
53 | name: _Paths.DASHBOARD, | 55 | name: _Paths.DASHBOARD, |
54 | page: () => DashboardView(), | 56 | page: () => DashboardView(), |
55 | - binding: DashboardBinding(), | 57 | + bindings: [ |
58 | + DashboardBinding(), | ||
59 | + ], | ||
56 | ), | 60 | ), |
57 | GetPage( | 61 | GetPage( |
58 | middlewares: [ | 62 | middlewares: [ |
@@ -63,19 +67,19 @@ class AppPages { | @@ -63,19 +67,19 @@ class AppPages { | ||
63 | page: () => ProfileView(), | 67 | page: () => ProfileView(), |
64 | title: 'Profile', | 68 | title: 'Profile', |
65 | transition: Transition.size, | 69 | transition: Transition.size, |
66 | - binding: ProfileBinding(), | 70 | + bindings: [ProfileBinding()], |
67 | ), | 71 | ), |
68 | GetPage( | 72 | GetPage( |
69 | name: _Paths.PRODUCTS, | 73 | name: _Paths.PRODUCTS, |
70 | page: () => ProductsView(), | 74 | page: () => ProductsView(), |
71 | title: 'Products', | 75 | title: 'Products', |
72 | transition: Transition.zoom, | 76 | transition: Transition.zoom, |
73 | - binding: ProductsBinding(), | 77 | + bindings: [ProductsBinding()], |
74 | children: [ | 78 | children: [ |
75 | GetPage( | 79 | GetPage( |
76 | name: _Paths.PRODUCT_DETAILS, | 80 | name: _Paths.PRODUCT_DETAILS, |
77 | page: () => ProductDetailsView(), | 81 | page: () => ProductDetailsView(), |
78 | - binding: ProductDetailsBinding(), | 82 | + bindings: [ProductDetailsBinding()], |
79 | middlewares: [ | 83 | middlewares: [ |
80 | //only enter this route when authed | 84 | //only enter this route when authed |
81 | EnsureAuthMiddleware(), | 85 | EnsureAuthMiddleware(), |
@@ -88,7 +92,9 @@ class AppPages { | @@ -88,7 +92,9 @@ class AppPages { | ||
88 | GetPage( | 92 | GetPage( |
89 | name: _Paths.SETTINGS, | 93 | name: _Paths.SETTINGS, |
90 | page: () => SettingsView(), | 94 | page: () => SettingsView(), |
91 | - binding: SettingsBinding(), | 95 | + bindings: [ |
96 | + SettingsBinding(), | ||
97 | + ], | ||
92 | ), | 98 | ), |
93 | ], | 99 | ], |
94 | ), | 100 | ), |
@@ -7,7 +7,7 @@ export 'get_common/get_reset.dart'; | @@ -7,7 +7,7 @@ export 'get_common/get_reset.dart'; | ||
7 | export 'get_connect/connect.dart'; | 7 | export 'get_connect/connect.dart'; |
8 | export 'get_core/get_core.dart'; | 8 | export 'get_core/get_core.dart'; |
9 | export 'get_instance/get_instance.dart'; | 9 | export 'get_instance/get_instance.dart'; |
10 | -export 'get_navigation/get_navigation.dart'; | 10 | +export 'get_navigation/get_navigation.dart' hide FirstWhereOrNullExt; |
11 | export 'get_rx/get_rx.dart'; | 11 | export 'get_rx/get_rx.dart'; |
12 | export 'get_state_manager/get_state_manager.dart'; | 12 | export 'get_state_manager/get_state_manager.dart'; |
13 | export 'get_utils/get_utils.dart'; | 13 | export 'get_utils/get_utils.dart'; |
@@ -5,7 +5,6 @@ import 'package:flutter/scheduler.dart'; | @@ -5,7 +5,6 @@ import 'package:flutter/scheduler.dart'; | ||
5 | 5 | ||
6 | import '../../get_core/get_core.dart'; | 6 | import '../../get_core/get_core.dart'; |
7 | import '../../get_instance/src/bindings_interface.dart'; | 7 | import '../../get_instance/src/bindings_interface.dart'; |
8 | -import '../../get_state_manager/src/simple/get_state.dart'; | ||
9 | import '../../get_utils/get_utils.dart'; | 8 | import '../../get_utils/get_utils.dart'; |
10 | import '../get_navigation.dart'; | 9 | import '../get_navigation.dart'; |
11 | import 'dialog/dialog_route.dart'; | 10 | import 'dialog/dialog_route.dart'; |
@@ -512,7 +511,7 @@ extension GetNavigationExt on GetInterface { | @@ -512,7 +511,7 @@ extension GetNavigationExt on GetInterface { | ||
512 | String? routeName, | 511 | String? routeName, |
513 | bool fullscreenDialog = false, | 512 | bool fullscreenDialog = false, |
514 | dynamic arguments, | 513 | dynamic arguments, |
515 | - Binding? binding, | 514 | + List<BindingsInterface>? bindings, |
516 | bool preventDuplicates = true, | 515 | bool preventDuplicates = true, |
517 | bool? popGesture, | 516 | bool? popGesture, |
518 | bool showCupertinoParallax = true, | 517 | bool showCupertinoParallax = true, |
@@ -530,7 +529,7 @@ extension GetNavigationExt on GetInterface { | @@ -530,7 +529,7 @@ extension GetNavigationExt on GetInterface { | ||
530 | routeName: routeName, | 529 | routeName: routeName, |
531 | fullscreenDialog: fullscreenDialog, | 530 | fullscreenDialog: fullscreenDialog, |
532 | arguments: arguments, | 531 | arguments: arguments, |
533 | - binding: binding, | 532 | + bindings: bindings, |
534 | preventDuplicates: preventDuplicates, | 533 | preventDuplicates: preventDuplicates, |
535 | popGesture: popGesture, | 534 | popGesture: popGesture, |
536 | showCupertinoParallax: showCupertinoParallax, | 535 | showCupertinoParallax: showCupertinoParallax, |
@@ -802,6 +801,13 @@ extension GetNavigationExt on GetInterface { | @@ -802,6 +801,13 @@ extension GetNavigationExt on GetInterface { | ||
802 | bool canPop = true, | 801 | bool canPop = true, |
803 | int? id, | 802 | int? id, |
804 | }) { | 803 | }) { |
804 | + //TODO: remove this when change own api to Dialog and BottomSheets | ||
805 | + //to declarative way | ||
806 | + if (isDialogOpen! || isBottomSheetOpen!) { | ||
807 | + searchDelegate(id).navigatorKey.currentState?.pop(); | ||
808 | + return; | ||
809 | + } | ||
810 | + | ||
805 | //TODO: This code brings compatibility of the new snackbar with GetX 4, | 811 | //TODO: This code brings compatibility of the new snackbar with GetX 4, |
806 | // remove this code in version 5 | 812 | // remove this code in version 5 |
807 | if (isSnackbarOpen && !closeOverlays) { | 813 | if (isSnackbarOpen && !closeOverlays) { |
@@ -816,8 +822,10 @@ extension GetNavigationExt on GetInterface { | @@ -816,8 +822,10 @@ extension GetNavigationExt on GetInterface { | ||
816 | closeAllSnackbars(); | 822 | closeAllSnackbars(); |
817 | } | 823 | } |
818 | 824 | ||
819 | - searchDelegate(id) | ||
820 | - .backUntil((route) => (!isDialogOpen! && !isBottomSheetOpen!)); | 825 | + while ((isDialogOpen! && isBottomSheetOpen!)) { |
826 | + searchDelegate(id).navigatorKey.currentState?.pop(); | ||
827 | + } | ||
828 | + | ||
821 | // navigator?.popUntil((route) { | 829 | // navigator?.popUntil((route) { |
822 | // return; | 830 | // return; |
823 | // }); | 831 | // }); |
@@ -881,7 +889,7 @@ extension GetNavigationExt on GetInterface { | @@ -881,7 +889,7 @@ extension GetNavigationExt on GetInterface { | ||
881 | int? id, | 889 | int? id, |
882 | String? routeName, | 890 | String? routeName, |
883 | dynamic arguments, | 891 | dynamic arguments, |
884 | - Binding? binding, | 892 | + List<BindingsInterface>? bindings, |
885 | bool fullscreenDialog = false, | 893 | bool fullscreenDialog = false, |
886 | bool preventDuplicates = true, | 894 | bool preventDuplicates = true, |
887 | Duration? duration, | 895 | Duration? duration, |
@@ -901,7 +909,7 @@ extension GetNavigationExt on GetInterface { | @@ -901,7 +909,7 @@ extension GetNavigationExt on GetInterface { | ||
901 | id: id, | 909 | id: id, |
902 | routeName: routeName, | 910 | routeName: routeName, |
903 | arguments: arguments, | 911 | arguments: arguments, |
904 | - binding: binding, | 912 | + bindings: bindings, |
905 | fullscreenDialog: fullscreenDialog, | 913 | fullscreenDialog: fullscreenDialog, |
906 | preventDuplicates: preventDuplicates, | 914 | preventDuplicates: preventDuplicates, |
907 | duration: duration, | 915 | duration: duration, |
@@ -960,7 +968,7 @@ extension GetNavigationExt on GetInterface { | @@ -960,7 +968,7 @@ extension GetNavigationExt on GetInterface { | ||
960 | int? id, | 968 | int? id, |
961 | String? routeName, | 969 | String? routeName, |
962 | dynamic arguments, | 970 | dynamic arguments, |
963 | - Binding? binding, | 971 | + List<BindingsInterface>? bindings, |
964 | bool fullscreenDialog = false, | 972 | bool fullscreenDialog = false, |
965 | Transition? transition, | 973 | Transition? transition, |
966 | Curve? curve, | 974 | Curve? curve, |
@@ -977,7 +985,7 @@ extension GetNavigationExt on GetInterface { | @@ -977,7 +985,7 @@ extension GetNavigationExt on GetInterface { | ||
977 | id: id, | 985 | id: id, |
978 | // routeName routeName, | 986 | // routeName routeName, |
979 | arguments: arguments, | 987 | arguments: arguments, |
980 | - binding: binding, | 988 | + bindings: bindings, |
981 | fullscreenDialog: fullscreenDialog, | 989 | fullscreenDialog: fullscreenDialog, |
982 | transition: transition, | 990 | transition: transition, |
983 | curve: curve, | 991 | curve: curve, |
@@ -1083,7 +1091,6 @@ extension GetNavigationExt on GetInterface { | @@ -1083,7 +1091,6 @@ extension GetNavigationExt on GetInterface { | ||
1083 | GetDelegate _key; | 1091 | GetDelegate _key; |
1084 | if (k == null) { | 1092 | if (k == null) { |
1085 | _key = Get.rootController.rootDelegate; | 1093 | _key = Get.rootController.rootDelegate; |
1086 | - print(_key.navigatorKey); | ||
1087 | } else { | 1094 | } else { |
1088 | if (!keys.containsKey(k)) { | 1095 | if (!keys.containsKey(k)) { |
1089 | throw 'Route id ($k) not found'; | 1096 | throw 'Route id ($k) not found'; |
@@ -1105,7 +1112,8 @@ extension GetNavigationExt on GetInterface { | @@ -1105,7 +1112,8 @@ extension GetNavigationExt on GetInterface { | ||
1105 | } | 1112 | } |
1106 | 1113 | ||
1107 | /// give current arguments | 1114 | /// give current arguments |
1108 | - dynamic get arguments => routing.args; | 1115 | + //dynamic get arguments => routing.args; |
1116 | + dynamic get arguments => _getxController.rootDelegate.arguments(); | ||
1109 | 1117 | ||
1110 | /// give name from current route | 1118 | /// give name from current route |
1111 | String get currentRoute => routing.current; | 1119 | String get currentRoute => routing.current; |
@@ -114,24 +114,10 @@ class GetCupertinoApp extends StatelessWidget { | @@ -114,24 +114,10 @@ class GetCupertinoApp extends StatelessWidget { | ||
114 | this.highContrastTheme, | 114 | this.highContrastTheme, |
115 | this.highContrastDarkTheme, | 115 | this.highContrastDarkTheme, |
116 | this.actions, | 116 | this.actions, |
117 | - }) : routerDelegate = Get.createDelegate( | ||
118 | - pages: getPages ?? | ||
119 | - [ | ||
120 | - GetPage( | ||
121 | - name: _cleanRouteName("/${home.runtimeType}"), | ||
122 | - page: () => home!, | ||
123 | - ), | ||
124 | - ], | ||
125 | - notFoundRoute: unknownRoute, | ||
126 | - navigatorKey: navigatorKey, | ||
127 | - ), | ||
128 | - routeInformationParser = Get.createInformationParser( | ||
129 | - initialRoute: initialRoute ?? | ||
130 | - getPages?.first.name ?? | ||
131 | - _cleanRouteName("/${home.runtimeType}"), | ||
132 | - ), | ||
133 | - routeInformationProvider = null, | 117 | + }) : routeInformationProvider = null, |
134 | backButtonDispatcher = null, | 118 | backButtonDispatcher = null, |
119 | + routeInformationParser = null, | ||
120 | + routerDelegate = null, | ||
135 | super(key: key); | 121 | super(key: key); |
136 | 122 | ||
137 | static String _cleanRouteName(String name) { | 123 | static String _cleanRouteName(String name) { |
@@ -149,8 +135,8 @@ class GetCupertinoApp extends StatelessWidget { | @@ -149,8 +135,8 @@ class GetCupertinoApp extends StatelessWidget { | ||
149 | Key? key, | 135 | Key? key, |
150 | this.theme, | 136 | this.theme, |
151 | this.routeInformationProvider, | 137 | this.routeInformationProvider, |
152 | - RouteInformationParser<Object>? routeInformationParser, | ||
153 | - RouterDelegate<Object>? routerDelegate, | 138 | + this.routeInformationParser, |
139 | + this.routerDelegate, | ||
154 | this.backButtonDispatcher, | 140 | this.backButtonDispatcher, |
155 | this.builder, | 141 | this.builder, |
156 | this.title = '', | 142 | this.title = '', |
@@ -190,33 +176,27 @@ class GetCupertinoApp extends StatelessWidget { | @@ -190,33 +176,27 @@ class GetCupertinoApp extends StatelessWidget { | ||
190 | this.transitionDuration, | 176 | this.transitionDuration, |
191 | this.defaultGlobalState, | 177 | this.defaultGlobalState, |
192 | this.getPages, | 178 | this.getPages, |
179 | + this.navigatorObservers, | ||
193 | this.unknownRoute, | 180 | this.unknownRoute, |
194 | - }) : routerDelegate = routerDelegate ??= Get.createDelegate( | ||
195 | - pages: getPages ?? [], | ||
196 | - notFoundRoute: unknownRoute, | ||
197 | - ), | ||
198 | - routeInformationParser = | ||
199 | - routeInformationParser ??= Get.createInformationParser( | ||
200 | - initialRoute: getPages?.first.name ?? '/', | ||
201 | - ), | ||
202 | - navigatorObservers = null, | ||
203 | - navigatorKey = null, | 181 | + }) : navigatorKey = null, |
204 | onGenerateRoute = null, | 182 | onGenerateRoute = null, |
205 | home = null, | 183 | home = null, |
206 | onGenerateInitialRoutes = null, | 184 | onGenerateInitialRoutes = null, |
207 | onUnknownRoute = null, | 185 | onUnknownRoute = null, |
208 | routes = null, | 186 | routes = null, |
209 | initialRoute = null, | 187 | initialRoute = null, |
210 | - super(key: key) { | ||
211 | - Get.routerDelegate = routerDelegate; | ||
212 | - Get.routeInformationParser = routeInformationParser; | ||
213 | - } | 188 | + super(key: key); |
214 | 189 | ||
215 | @override | 190 | @override |
216 | Widget build(BuildContext context) => GetBuilder<GetMaterialController>( | 191 | Widget build(BuildContext context) => GetBuilder<GetMaterialController>( |
217 | init: Get.rootController, | 192 | init: Get.rootController, |
218 | dispose: (d) { | 193 | dispose: (d) { |
219 | onDispose?.call(); | 194 | onDispose?.call(); |
195 | + Get.clearRouteTree(); | ||
196 | + Get.clearTranslations(); | ||
197 | + Get.resetRootNavigator(); | ||
198 | + Get.routerDelegate = null; | ||
199 | + Get.routeInformationParser = null; | ||
220 | }, | 200 | }, |
221 | initState: (i) { | 201 | initState: (i) { |
222 | Get.engine!.addPostFrameCallback((timeStamp) { | 202 | Get.engine!.addPostFrameCallback((timeStamp) { |
@@ -237,6 +217,13 @@ class GetCupertinoApp extends StatelessWidget { | @@ -237,6 +217,13 @@ class GetCupertinoApp extends StatelessWidget { | ||
237 | initialBinding?.dependencies(); | 217 | initialBinding?.dependencies(); |
238 | if (getPages != null) { | 218 | if (getPages != null) { |
239 | Get.addPages(getPages!); | 219 | Get.addPages(getPages!); |
220 | + } else { | ||
221 | + Get.addPage( | ||
222 | + GetPage( | ||
223 | + name: _cleanRouteName("/${home.runtimeType}"), | ||
224 | + page: () => home!, | ||
225 | + ), | ||
226 | + ); | ||
240 | } | 227 | } |
241 | 228 | ||
242 | Get.smartManagement = smartManagement; | 229 | Get.smartManagement = smartManagement; |
@@ -252,46 +239,11 @@ class GetCupertinoApp extends StatelessWidget { | @@ -252,46 +239,11 @@ class GetCupertinoApp extends StatelessWidget { | ||
252 | transitionDuration ?? Get.defaultTransitionDuration, | 239 | transitionDuration ?? Get.defaultTransitionDuration, |
253 | ); | 240 | ); |
254 | }, | 241 | }, |
255 | - builder: (_) => routerDelegate != null | ||
256 | - ? CupertinoApp.router( | ||
257 | - routerDelegate: routerDelegate!, | ||
258 | - routeInformationParser: routeInformationParser!, | ||
259 | - backButtonDispatcher: backButtonDispatcher, | ||
260 | - routeInformationProvider: routeInformationProvider, | ||
261 | - key: _.unikey, | ||
262 | - theme: theme, | ||
263 | - builder: defaultBuilder, | ||
264 | - title: title, | ||
265 | - onGenerateTitle: onGenerateTitle, | ||
266 | - color: color, | ||
267 | - locale: Get.locale ?? locale, | ||
268 | - localizationsDelegates: localizationsDelegates, | ||
269 | - localeListResolutionCallback: localeListResolutionCallback, | ||
270 | - localeResolutionCallback: localeResolutionCallback, | ||
271 | - supportedLocales: supportedLocales, | ||
272 | - showPerformanceOverlay: showPerformanceOverlay, | ||
273 | - checkerboardRasterCacheImages: checkerboardRasterCacheImages, | ||
274 | - checkerboardOffscreenLayers: checkerboardOffscreenLayers, | ||
275 | - showSemanticsDebugger: showSemanticsDebugger, | ||
276 | - debugShowCheckedModeBanner: debugShowCheckedModeBanner, | ||
277 | - shortcuts: shortcuts, | ||
278 | - useInheritedMediaQuery: useInheritedMediaQuery, | ||
279 | - ) | ||
280 | - : CupertinoApp( | ||
281 | - key: _.unikey, | ||
282 | - theme: theme, | ||
283 | - navigatorKey: (navigatorKey == null | ||
284 | - ? Get.key | ||
285 | - : Get.addKey(navigatorKey!)), | ||
286 | - home: home, | ||
287 | - routes: routes ?? const <String, WidgetBuilder>{}, | ||
288 | - initialRoute: initialRoute, | ||
289 | - onGenerateRoute: | ||
290 | - (getPages != null ? generator : onGenerateRoute), | ||
291 | - onGenerateInitialRoutes: (getPages == null || home != null) | ||
292 | - ? onGenerateInitialRoutes | ||
293 | - : initialRoutesGenerate, | ||
294 | - onUnknownRoute: onUnknownRoute, | 242 | + builder: (_) { |
243 | + final routerDelegate = Get.createDelegate( | ||
244 | + pages: getPages ?? [], | ||
245 | + notFoundRoute: unknownRoute, | ||
246 | + navigatorKey: navigatorKey, | ||
295 | navigatorObservers: (navigatorObservers == null | 247 | navigatorObservers: (navigatorObservers == null |
296 | ? <NavigatorObserver>[ | 248 | ? <NavigatorObserver>[ |
297 | GetObserver(routingCallback, Get.routing) | 249 | GetObserver(routingCallback, Get.routing) |
@@ -299,7 +251,20 @@ class GetCupertinoApp extends StatelessWidget { | @@ -299,7 +251,20 @@ class GetCupertinoApp extends StatelessWidget { | ||
299 | : <NavigatorObserver>[ | 251 | : <NavigatorObserver>[ |
300 | GetObserver(routingCallback, Get.routing) | 252 | GetObserver(routingCallback, Get.routing) |
301 | ] | 253 | ] |
302 | - ..addAll(navigatorObservers!)), | 254 | + ..addAll(navigatorObservers!))); |
255 | + final routeInformationParser = Get.createInformationParser( | ||
256 | + initialRoute: initialRoute ?? | ||
257 | + getPages?.first.name ?? | ||
258 | + _cleanRouteName("/${home.runtimeType}"), | ||
259 | + ); | ||
260 | + | ||
261 | + return CupertinoApp.router( | ||
262 | + routerDelegate: routerDelegate, | ||
263 | + routeInformationParser: routeInformationParser, | ||
264 | + backButtonDispatcher: backButtonDispatcher, | ||
265 | + routeInformationProvider: routeInformationProvider, | ||
266 | + key: _.unikey, | ||
267 | + theme: theme, | ||
303 | builder: defaultBuilder, | 268 | builder: defaultBuilder, |
304 | title: title, | 269 | title: title, |
305 | onGenerateTitle: onGenerateTitle, | 270 | onGenerateTitle: onGenerateTitle, |
@@ -316,8 +281,8 @@ class GetCupertinoApp extends StatelessWidget { | @@ -316,8 +281,8 @@ class GetCupertinoApp extends StatelessWidget { | ||
316 | debugShowCheckedModeBanner: debugShowCheckedModeBanner, | 281 | debugShowCheckedModeBanner: debugShowCheckedModeBanner, |
317 | shortcuts: shortcuts, | 282 | shortcuts: shortcuts, |
318 | useInheritedMediaQuery: useInheritedMediaQuery, | 283 | useInheritedMediaQuery: useInheritedMediaQuery, |
319 | - // actions: actions, | ||
320 | - ), | 284 | + ); |
285 | + }, | ||
321 | ); | 286 | ); |
322 | 287 | ||
323 | Widget defaultBuilder(BuildContext context, Widget? child) { | 288 | Widget defaultBuilder(BuildContext context, Widget? child) { |
@@ -7,64 +7,6 @@ import '../../../get_state_manager/get_state_manager.dart'; | @@ -7,64 +7,6 @@ import '../../../get_state_manager/get_state_manager.dart'; | ||
7 | import '../../../get_utils/get_utils.dart'; | 7 | import '../../../get_utils/get_utils.dart'; |
8 | import '../../get_navigation.dart'; | 8 | import '../../get_navigation.dart'; |
9 | 9 | ||
10 | -// extension GetMaterialExt on MaterialApp{ | ||
11 | -// MaterialApp get(){ | ||
12 | -// final app = MaterialApp.router( | ||
13 | -// key: key, | ||
14 | -// routeInformationProvider:routeInformationProvider, | ||
15 | -// scaffoldMessengerKey:scaffoldMessengerKey, | ||
16 | -// // RouteInformationParser<Object>? routeInformationParser, | ||
17 | -// // RouterDelegate<Object>? routerDelegate, | ||
18 | -// backButtonDispatcher:backButtonDispatcher, | ||
19 | -// builder:builder, | ||
20 | -// title:title, | ||
21 | -// onGenerateTitle:onGenerateTitle, | ||
22 | -// color:color, | ||
23 | -// theme:theme, | ||
24 | -// darkTheme:darkTheme, | ||
25 | -// useInheritedMediaQuery:useInheritedMediaQuery, | ||
26 | -// highContrastTheme:highContrastTheme, | ||
27 | -// highContrastDarkTheme:highContrastDarkTheme, | ||
28 | -// themeMode :themeMode, | ||
29 | -// locale:locale, | ||
30 | -// localizationsDelegates:localizationsDelegates, | ||
31 | -// localeListResolutionCallback: localeListResolutionCallback, | ||
32 | -// localeResolutionCallback: localeResolutionCallback, | ||
33 | -// supportedLocales: supportedLocales, | ||
34 | -// debugShowMaterialGrid :debugShowMaterialGrid, | ||
35 | -// showPerformanceOverlay :showPerformanceOverlay, | ||
36 | -// checkerboardRasterCacheImages :checkerboardRasterCacheImages, | ||
37 | -// checkerboardOffscreenLayers :checkerboardOffscreenLayers, | ||
38 | -// showSemanticsDebugger :showSemanticsDebugger, | ||
39 | -// debugShowCheckedModeBanner :debugShowCheckedModeBanner, | ||
40 | -// shortcuts: shortcuts, | ||
41 | -// scrollBehavior:scrollBehavior, | ||
42 | -// actions:actions, | ||
43 | -// customTransition:customTransition, | ||
44 | -// translationsKeys:translationsKeys, | ||
45 | -// translations:translations, | ||
46 | -// textDirection:textDirection, | ||
47 | -// fallbackLocale:fallbackLocale, | ||
48 | -// routingCallback:routingCallback, | ||
49 | -// defaultTransition:defaultTransition, | ||
50 | -// opaqueRoute:opaqueRoute, | ||
51 | -// onInit:onInit, | ||
52 | -// onReady:onReady, | ||
53 | -// onDispose:onDispose, | ||
54 | -// enableLog:enableLog, | ||
55 | -// logWriterCallback:logWriterCallback, | ||
56 | -// popGesture:popGesture, | ||
57 | -// smartManagement:smartManagement | ||
58 | -// initialBinding:initialBinding, | ||
59 | -// transitionDuration:transitionDuration, | ||
60 | -// defaultGlobalState:defaultGlobalState, | ||
61 | -// getPages:getPages, | ||
62 | -// navigatorObservers: navigatorObservers, | ||
63 | -// unknownRoute:unknownRoute, | ||
64 | -// ); | ||
65 | -// } | ||
66 | -// } | ||
67 | - | ||
68 | class GetMaterialApp extends StatelessWidget { | 10 | class GetMaterialApp extends StatelessWidget { |
69 | final GlobalKey<NavigatorState>? navigatorKey; | 11 | final GlobalKey<NavigatorState>? navigatorKey; |
70 | 12 | ||
@@ -181,24 +123,10 @@ class GetMaterialApp extends StatelessWidget { | @@ -181,24 +123,10 @@ class GetMaterialApp extends StatelessWidget { | ||
181 | this.highContrastTheme, | 123 | this.highContrastTheme, |
182 | this.highContrastDarkTheme, | 124 | this.highContrastDarkTheme, |
183 | this.actions, | 125 | this.actions, |
184 | - }) : routerDelegate = Get.createDelegate( | ||
185 | - pages: getPages ?? | ||
186 | - [ | ||
187 | - GetPage( | ||
188 | - name: _cleanRouteName("/${home.runtimeType}"), | ||
189 | - page: () => home!, | ||
190 | - ), | ||
191 | - ], | ||
192 | - notFoundRoute: unknownRoute, | ||
193 | - navigatorKey: navigatorKey, | ||
194 | - ), | ||
195 | - routeInformationParser = Get.createInformationParser( | ||
196 | - initialRoute: initialRoute ?? | ||
197 | - getPages?.first.name ?? | ||
198 | - _cleanRouteName("/${home.runtimeType}"), | ||
199 | - ), | ||
200 | - routeInformationProvider = null, | 126 | + }) : routeInformationProvider = null, |
201 | backButtonDispatcher = null, | 127 | backButtonDispatcher = null, |
128 | + routeInformationParser = null, | ||
129 | + routerDelegate = null, | ||
202 | super(key: key); | 130 | super(key: key); |
203 | 131 | ||
204 | static String _cleanRouteName(String name) { | 132 | static String _cleanRouteName(String name) { |
@@ -216,8 +144,8 @@ class GetMaterialApp extends StatelessWidget { | @@ -216,8 +144,8 @@ class GetMaterialApp extends StatelessWidget { | ||
216 | Key? key, | 144 | Key? key, |
217 | this.routeInformationProvider, | 145 | this.routeInformationProvider, |
218 | this.scaffoldMessengerKey, | 146 | this.scaffoldMessengerKey, |
219 | - RouteInformationParser<Object>? routeInformationParser, | ||
220 | - RouterDelegate<Object>? routerDelegate, | 147 | + this.routeInformationParser, |
148 | + this.routerDelegate, | ||
221 | this.backButtonDispatcher, | 149 | this.backButtonDispatcher, |
222 | this.builder, | 150 | this.builder, |
223 | this.title = '', | 151 | this.title = '', |
@@ -264,33 +192,29 @@ class GetMaterialApp extends StatelessWidget { | @@ -264,33 +192,29 @@ class GetMaterialApp extends StatelessWidget { | ||
264 | this.getPages, | 192 | this.getPages, |
265 | this.navigatorObservers, | 193 | this.navigatorObservers, |
266 | this.unknownRoute, | 194 | this.unknownRoute, |
267 | - }) : routerDelegate = routerDelegate ??= Get.createDelegate( | ||
268 | - pages: getPages ?? [], | ||
269 | - notFoundRoute: unknownRoute, | ||
270 | - ), | ||
271 | - routeInformationParser = | ||
272 | - routeInformationParser ??= Get.createInformationParser( | ||
273 | - initialRoute: getPages?.first.name ?? '/', | ||
274 | - ), | ||
275 | - navigatorKey = null, | 195 | + }) : navigatorKey = null, |
276 | onGenerateRoute = null, | 196 | onGenerateRoute = null, |
277 | home = null, | 197 | home = null, |
278 | onGenerateInitialRoutes = null, | 198 | onGenerateInitialRoutes = null, |
279 | onUnknownRoute = null, | 199 | onUnknownRoute = null, |
280 | routes = null, | 200 | routes = null, |
281 | initialRoute = null, | 201 | initialRoute = null, |
282 | - super(key: key) { | ||
283 | - Get.routerDelegate = routerDelegate; | ||
284 | - Get.routeInformationParser = routeInformationParser; | ||
285 | - } | 202 | + super(key: key); |
286 | 203 | ||
287 | @override | 204 | @override |
288 | Widget build(BuildContext context) => GetBuilder<GetMaterialController>( | 205 | Widget build(BuildContext context) => GetBuilder<GetMaterialController>( |
289 | init: Get.rootController, | 206 | init: Get.rootController, |
290 | dispose: (d) { | 207 | dispose: (d) { |
291 | onDispose?.call(); | 208 | onDispose?.call(); |
209 | + Get.clearRouteTree(); | ||
210 | + Get.clearTranslations(); | ||
211 | + Get.resetRootNavigator(); | ||
212 | + Get.routerDelegate = null; | ||
213 | + Get.routeInformationParser = null; | ||
292 | }, | 214 | }, |
293 | initState: (i) { | 215 | initState: (i) { |
216 | + // Get.routerDelegate = routerDelegate; | ||
217 | + // Get.routeInformationParser = routeInformationParser; | ||
294 | Get.engine!.addPostFrameCallback((timeStamp) { | 218 | Get.engine!.addPostFrameCallback((timeStamp) { |
295 | onReady?.call(); | 219 | onReady?.call(); |
296 | }); | 220 | }); |
@@ -309,6 +233,13 @@ class GetMaterialApp extends StatelessWidget { | @@ -309,6 +233,13 @@ class GetMaterialApp extends StatelessWidget { | ||
309 | initialBinding?.dependencies(); | 233 | initialBinding?.dependencies(); |
310 | if (getPages != null) { | 234 | if (getPages != null) { |
311 | Get.addPages(getPages!); | 235 | Get.addPages(getPages!); |
236 | + } else { | ||
237 | + Get.addPage( | ||
238 | + GetPage( | ||
239 | + name: _cleanRouteName("/${home.runtimeType}"), | ||
240 | + page: () => home!, | ||
241 | + ), | ||
242 | + ); | ||
312 | } | 243 | } |
313 | 244 | ||
314 | //Get.setDefaultDelegate(routerDelegate); | 245 | //Get.setDefaultDelegate(routerDelegate); |
@@ -325,10 +256,23 @@ class GetMaterialApp extends StatelessWidget { | @@ -325,10 +256,23 @@ class GetMaterialApp extends StatelessWidget { | ||
325 | transitionDuration ?? Get.defaultTransitionDuration, | 256 | transitionDuration ?? Get.defaultTransitionDuration, |
326 | ); | 257 | ); |
327 | }, | 258 | }, |
328 | - builder: (_) => routerDelegate != null | ||
329 | - ? MaterialApp.router( | ||
330 | - routerDelegate: routerDelegate!, | ||
331 | - routeInformationParser: routeInformationParser!, | 259 | + builder: (_) { |
260 | + final routerDelegate = Get.createDelegate( | ||
261 | + pages: getPages ?? [], | ||
262 | + notFoundRoute: unknownRoute, | ||
263 | + navigatorKey: navigatorKey, | ||
264 | + navigatorObservers: (navigatorObservers == null | ||
265 | + ? <NavigatorObserver>[GetObserver(routingCallback, Get.routing)] | ||
266 | + : <NavigatorObserver>[GetObserver(routingCallback, Get.routing)] | ||
267 | + ..addAll(navigatorObservers!))); | ||
268 | + final routeInformationParser = Get.createInformationParser( | ||
269 | + initialRoute: initialRoute ?? | ||
270 | + getPages?.first.name ?? | ||
271 | + _cleanRouteName("/${home.runtimeType}"), | ||
272 | + ); | ||
273 | + return MaterialApp.router( | ||
274 | + routerDelegate: routerDelegate, | ||
275 | + routeInformationParser: routeInformationParser, | ||
332 | backButtonDispatcher: backButtonDispatcher, | 276 | backButtonDispatcher: backButtonDispatcher, |
333 | routeInformationProvider: routeInformationProvider, | 277 | routeInformationProvider: routeInformationProvider, |
334 | key: _.unikey, | 278 | key: _.unikey, |
@@ -337,59 +281,10 @@ class GetMaterialApp extends StatelessWidget { | @@ -337,59 +281,10 @@ class GetMaterialApp extends StatelessWidget { | ||
337 | onGenerateTitle: onGenerateTitle, | 281 | onGenerateTitle: onGenerateTitle, |
338 | color: color, | 282 | color: color, |
339 | theme: _.theme ?? theme ?? ThemeData.fallback(), | 283 | theme: _.theme ?? theme ?? ThemeData.fallback(), |
340 | - darkTheme: | ||
341 | - _.darkTheme ?? darkTheme ?? theme ?? ThemeData.fallback(), | ||
342 | - themeMode: _.themeMode ?? themeMode, | ||
343 | - locale: Get.locale ?? locale, | ||
344 | - scaffoldMessengerKey: | ||
345 | - scaffoldMessengerKey ?? _.scaffoldMessengerKey, | ||
346 | - localizationsDelegates: localizationsDelegates, | ||
347 | - localeListResolutionCallback: localeListResolutionCallback, | ||
348 | - localeResolutionCallback: localeResolutionCallback, | ||
349 | - supportedLocales: supportedLocales, | ||
350 | - debugShowMaterialGrid: debugShowMaterialGrid, | ||
351 | - showPerformanceOverlay: showPerformanceOverlay, | ||
352 | - checkerboardRasterCacheImages: checkerboardRasterCacheImages, | ||
353 | - checkerboardOffscreenLayers: checkerboardOffscreenLayers, | ||
354 | - showSemanticsDebugger: showSemanticsDebugger, | ||
355 | - debugShowCheckedModeBanner: debugShowCheckedModeBanner, | ||
356 | - shortcuts: shortcuts, | ||
357 | - scrollBehavior: scrollBehavior, | ||
358 | - useInheritedMediaQuery: useInheritedMediaQuery, | ||
359 | - ) | ||
360 | - : MaterialApp( | ||
361 | - key: _.unikey, | ||
362 | - navigatorKey: (navigatorKey == null | ||
363 | - ? Get.key | ||
364 | - : Get.addKey(navigatorKey!)), | ||
365 | - scaffoldMessengerKey: | ||
366 | - scaffoldMessengerKey ?? _.scaffoldMessengerKey, | ||
367 | - home: home, | ||
368 | - routes: routes ?? const <String, WidgetBuilder>{}, | ||
369 | - initialRoute: initialRoute, | ||
370 | - onGenerateRoute: | ||
371 | - (getPages != null ? generator : onGenerateRoute), | ||
372 | - onGenerateInitialRoutes: (getPages == null || home != null) | ||
373 | - ? onGenerateInitialRoutes | ||
374 | - : initialRoutesGenerate, | ||
375 | - onUnknownRoute: onUnknownRoute, | ||
376 | - navigatorObservers: (navigatorObservers == null | ||
377 | - ? <NavigatorObserver>[ | ||
378 | - GetObserver(routingCallback, Get.routing) | ||
379 | - ] | ||
380 | - : <NavigatorObserver>[ | ||
381 | - GetObserver(routingCallback, Get.routing) | ||
382 | - ] | ||
383 | - ..addAll(navigatorObservers!)), | ||
384 | - builder: defaultBuilder, | ||
385 | - title: title, | ||
386 | - onGenerateTitle: onGenerateTitle, | ||
387 | - color: color, | ||
388 | - theme: _.theme ?? theme ?? ThemeData.fallback(), | ||
389 | - darkTheme: | ||
390 | - _.darkTheme ?? darkTheme ?? theme ?? ThemeData.fallback(), | 284 | + darkTheme: _.darkTheme ?? darkTheme ?? theme ?? ThemeData.fallback(), |
391 | themeMode: _.themeMode ?? themeMode, | 285 | themeMode: _.themeMode ?? themeMode, |
392 | locale: Get.locale ?? locale, | 286 | locale: Get.locale ?? locale, |
287 | + scaffoldMessengerKey: scaffoldMessengerKey ?? _.scaffoldMessengerKey, | ||
393 | localizationsDelegates: localizationsDelegates, | 288 | localizationsDelegates: localizationsDelegates, |
394 | localeListResolutionCallback: localeListResolutionCallback, | 289 | localeListResolutionCallback: localeListResolutionCallback, |
395 | localeResolutionCallback: localeResolutionCallback, | 290 | localeResolutionCallback: localeResolutionCallback, |
@@ -403,9 +298,8 @@ class GetMaterialApp extends StatelessWidget { | @@ -403,9 +298,8 @@ class GetMaterialApp extends StatelessWidget { | ||
403 | shortcuts: shortcuts, | 298 | shortcuts: shortcuts, |
404 | scrollBehavior: scrollBehavior, | 299 | scrollBehavior: scrollBehavior, |
405 | useInheritedMediaQuery: useInheritedMediaQuery, | 300 | useInheritedMediaQuery: useInheritedMediaQuery, |
406 | - // actions: actions, | ||
407 | - ), | ||
408 | ); | 301 | ); |
302 | + }); | ||
409 | 303 | ||
410 | Widget defaultBuilder(BuildContext context, Widget? child) { | 304 | Widget defaultBuilder(BuildContext context, Widget? child) { |
411 | return Directionality( | 305 | return Directionality( |
@@ -423,12 +317,12 @@ class GetMaterialApp extends StatelessWidget { | @@ -423,12 +317,12 @@ class GetMaterialApp extends StatelessWidget { | ||
423 | return PageRedirect(settings: settings, unknownRoute: unknownRoute).page(); | 317 | return PageRedirect(settings: settings, unknownRoute: unknownRoute).page(); |
424 | } | 318 | } |
425 | 319 | ||
426 | - List<Route<dynamic>> initialRoutesGenerate(String name) { | ||
427 | - return [ | ||
428 | - PageRedirect( | ||
429 | - settings: RouteSettings(name: name), | ||
430 | - unknownRoute: unknownRoute, | ||
431 | - ).page() | ||
432 | - ]; | ||
433 | - } | 320 | + // List<Route<dynamic>> initialRoutesGenerate(String name) { |
321 | + // return [ | ||
322 | + // PageRedirect( | ||
323 | + // settings: RouteSettings(name: name), | ||
324 | + // unknownRoute: unknownRoute, | ||
325 | + // ).page() | ||
326 | + // ]; | ||
327 | + // } | ||
434 | } | 328 | } |
@@ -2,7 +2,9 @@ import 'package:flutter/material.dart'; | @@ -2,7 +2,9 @@ import 'package:flutter/material.dart'; | ||
2 | 2 | ||
3 | import '../../../get.dart'; | 3 | import '../../../get.dart'; |
4 | 4 | ||
5 | -class GetMaterialController extends SuperController { | 5 | +class GetMaterialController extends FullLifeCycleController { |
6 | + static GetMaterialController get to => Get.find(); | ||
7 | + | ||
6 | bool testMode = false; | 8 | bool testMode = false; |
7 | Key? unikey; | 9 | Key? unikey; |
8 | ThemeData? theme; | 10 | ThemeData? theme; |
@@ -49,18 +51,6 @@ class GetMaterialController extends SuperController { | @@ -49,18 +51,6 @@ class GetMaterialController extends SuperController { | ||
49 | }); | 51 | }); |
50 | } | 52 | } |
51 | 53 | ||
52 | - @override | ||
53 | - void onDetached() {} | ||
54 | - | ||
55 | - @override | ||
56 | - void onInactive() {} | ||
57 | - | ||
58 | - @override | ||
59 | - void onPaused() {} | ||
60 | - | ||
61 | - @override | ||
62 | - void onResumed() {} | ||
63 | - | ||
64 | void restartApp() { | 54 | void restartApp() { |
65 | unikey = UniqueKey(); | 55 | unikey = UniqueKey(); |
66 | update(); | 56 | update(); |
@@ -32,7 +32,7 @@ mixin PageRouteReportMixin<T> on Route<T> { | @@ -32,7 +32,7 @@ mixin PageRouteReportMixin<T> on Route<T> { | ||
32 | } | 32 | } |
33 | } | 33 | } |
34 | 34 | ||
35 | -class GetPageRoute<T> extends MaterialPageRoute<T> | 35 | +class GetPageRoute<T> extends PageRoute<T> |
36 | with GetPageRouteTransitionMixin<T>, PageRouteReportMixin { | 36 | with GetPageRouteTransitionMixin<T>, PageRouteReportMixin { |
37 | /// Creates a page route for use in an iOS designed app. | 37 | /// Creates a page route for use in an iOS designed app. |
38 | /// | 38 | /// |
@@ -51,7 +51,7 @@ class GetPageRoute<T> extends MaterialPageRoute<T> | @@ -51,7 +51,7 @@ class GetPageRoute<T> extends MaterialPageRoute<T> | ||
51 | this.customTransition, | 51 | this.customTransition, |
52 | this.barrierDismissible = false, | 52 | this.barrierDismissible = false, |
53 | this.barrierColor, | 53 | this.barrierColor, |
54 | - this.binding, | 54 | + this.bindings, |
55 | this.binds, | 55 | this.binds, |
56 | this.routeName, | 56 | this.routeName, |
57 | this.page, | 57 | this.page, |
@@ -64,7 +64,7 @@ class GetPageRoute<T> extends MaterialPageRoute<T> | @@ -64,7 +64,7 @@ class GetPageRoute<T> extends MaterialPageRoute<T> | ||
64 | }) : super( | 64 | }) : super( |
65 | settings: settings, | 65 | settings: settings, |
66 | fullscreenDialog: fullscreenDialog, | 66 | fullscreenDialog: fullscreenDialog, |
67 | - builder: (context) => Container(), | 67 | + // builder: (context) => Container(), |
68 | ); | 68 | ); |
69 | 69 | ||
70 | @override | 70 | @override |
@@ -73,7 +73,7 @@ class GetPageRoute<T> extends MaterialPageRoute<T> | @@ -73,7 +73,7 @@ class GetPageRoute<T> extends MaterialPageRoute<T> | ||
73 | final String? routeName; | 73 | final String? routeName; |
74 | //final String reference; | 74 | //final String reference; |
75 | final CustomTransition? customTransition; | 75 | final CustomTransition? customTransition; |
76 | - final BindingsInterface? binding; | 76 | + final List<BindingsInterface>? bindings; |
77 | final Map<String, String>? parameter; | 77 | final Map<String, String>? parameter; |
78 | final List<Bind>? binds; | 78 | final List<Bind>? binds; |
79 | 79 | ||
@@ -118,11 +118,11 @@ class GetPageRoute<T> extends MaterialPageRoute<T> | @@ -118,11 +118,11 @@ class GetPageRoute<T> extends MaterialPageRoute<T> | ||
118 | ]; | 118 | ]; |
119 | 119 | ||
120 | final localbindings = [ | 120 | final localbindings = [ |
121 | - if (binding != null) ...<BindingsInterface>[binding!], | 121 | + if (bindings != null) ...bindings!, |
122 | ]; | 122 | ]; |
123 | 123 | ||
124 | final bindingsToBind = middlewareRunner | 124 | final bindingsToBind = middlewareRunner |
125 | - .runOnBindingsStart(binding != null ? localbindings : localbinds); | 125 | + .runOnBindingsStart(bindings != null ? localbindings : localbinds); |
126 | 126 | ||
127 | /// Retrocompatibility workaround, remove this when Bindings api | 127 | /// Retrocompatibility workaround, remove this when Bindings api |
128 | /// have been removed | 128 | /// have been removed |
@@ -35,7 +35,7 @@ class GetInformationParser extends RouteInformationParser<RouteDecoder> { | @@ -35,7 +35,7 @@ class GetInformationParser extends RouteInformationParser<RouteDecoder> { | ||
35 | @override | 35 | @override |
36 | RouteInformation restoreRouteInformation(RouteDecoder config) { | 36 | RouteInformation restoreRouteInformation(RouteDecoder config) { |
37 | return RouteInformation( | 37 | return RouteInformation( |
38 | - location: config.arguments?.name, | 38 | + location: config.pageSettings?.name, |
39 | state: null, | 39 | state: null, |
40 | ); | 40 | ); |
41 | } | 41 | } |
1 | import 'package:flutter/widgets.dart'; | 1 | import 'package:flutter/widgets.dart'; |
2 | 2 | ||
3 | -import '../../../get_state_manager/src/simple/get_state.dart'; | 3 | +import '../../../get_instance/src/bindings_interface.dart'; |
4 | import '../routes/get_route.dart'; | 4 | import '../routes/get_route.dart'; |
5 | import '../routes/transitions_type.dart'; | 5 | import '../routes/transitions_type.dart'; |
6 | 6 | ||
@@ -15,7 +15,7 @@ mixin IGetNavigation { | @@ -15,7 +15,7 @@ mixin IGetNavigation { | ||
15 | String? routeName, | 15 | String? routeName, |
16 | bool fullscreenDialog = false, | 16 | bool fullscreenDialog = false, |
17 | dynamic arguments, | 17 | dynamic arguments, |
18 | - Binding? binding, | 18 | + List<BindingsInterface>? bindings, |
19 | bool preventDuplicates = true, | 19 | bool preventDuplicates = true, |
20 | bool? popGesture, | 20 | bool? popGesture, |
21 | bool showCupertinoParallax = true, | 21 | bool showCupertinoParallax = true, |
@@ -32,7 +32,7 @@ mixin IGetNavigation { | @@ -32,7 +32,7 @@ mixin IGetNavigation { | ||
32 | String? routeName, | 32 | String? routeName, |
33 | bool fullscreenDialog = false, | 33 | bool fullscreenDialog = false, |
34 | dynamic arguments, | 34 | dynamic arguments, |
35 | - Binding? binding, | 35 | + List<BindingsInterface>? bindings, |
36 | bool preventDuplicates = true, | 36 | bool preventDuplicates = true, |
37 | bool? popGesture, | 37 | bool? popGesture, |
38 | bool showCupertinoParallax = true, | 38 | bool showCupertinoParallax = true, |
@@ -47,7 +47,7 @@ mixin IGetNavigation { | @@ -47,7 +47,7 @@ mixin IGetNavigation { | ||
47 | int? id, | 47 | int? id, |
48 | String? routeName, | 48 | String? routeName, |
49 | dynamic arguments, | 49 | dynamic arguments, |
50 | - Binding? binding, | 50 | + List<BindingsInterface>? bindings, |
51 | bool fullscreenDialog = false, | 51 | bool fullscreenDialog = false, |
52 | Transition? transition, | 52 | Transition? transition, |
53 | Curve? curve, | 53 | Curve? curve, |
@@ -3,7 +3,6 @@ import 'dart:async'; | @@ -3,7 +3,6 @@ import 'dart:async'; | ||
3 | import 'package:flutter/cupertino.dart'; | 3 | import 'package:flutter/cupertino.dart'; |
4 | import 'package:flutter/material.dart'; | 4 | import 'package:flutter/material.dart'; |
5 | 5 | ||
6 | -import '../../../get_core/src/get_main.dart'; | ||
7 | import '../../../get_instance/src/bindings_interface.dart'; | 6 | import '../../../get_instance/src/bindings_interface.dart'; |
8 | import '../../../get_state_manager/src/simple/get_state.dart'; | 7 | import '../../../get_state_manager/src/simple/get_state.dart'; |
9 | import '../../get_navigation.dart'; | 8 | import '../../get_navigation.dart'; |
@@ -20,7 +19,8 @@ class GetPage<T> extends Page<T> { | @@ -20,7 +19,8 @@ class GetPage<T> extends Page<T> { | ||
20 | final bool maintainState; | 19 | final bool maintainState; |
21 | final bool opaque; | 20 | final bool opaque; |
22 | final double Function(BuildContext context)? gestureWidth; | 21 | final double Function(BuildContext context)? gestureWidth; |
23 | - final BindingsInterface? binding; | 22 | + //final BindingsInterface? binding; |
23 | + final List<BindingsInterface>? bindings; | ||
24 | final List<Bind> binds; | 24 | final List<Bind> binds; |
25 | final CustomTransition? customTransition; | 25 | final CustomTransition? customTransition; |
26 | final Duration? transitionDuration; | 26 | final Duration? transitionDuration; |
@@ -61,7 +61,7 @@ class GetPage<T> extends Page<T> { | @@ -61,7 +61,7 @@ class GetPage<T> extends Page<T> { | ||
61 | this.opaque = true, | 61 | this.opaque = true, |
62 | this.transitionDuration, | 62 | this.transitionDuration, |
63 | this.popGesture, | 63 | this.popGesture, |
64 | - this.binding, | 64 | + this.bindings = const [], |
65 | this.binds = const [], | 65 | this.binds = const [], |
66 | this.transition, | 66 | this.transition, |
67 | this.customTransition, | 67 | this.customTransition, |
@@ -81,7 +81,7 @@ class GetPage<T> extends Page<T> { | @@ -81,7 +81,7 @@ class GetPage<T> extends Page<T> { | ||
81 | super( | 81 | super( |
82 | key: ValueKey(name), | 82 | key: ValueKey(name), |
83 | name: name, | 83 | name: name, |
84 | - arguments: Get.arguments, | 84 | + // arguments: Get.arguments, |
85 | ); | 85 | ); |
86 | // settings = RouteSettings(name: name, arguments: Get.arguments); | 86 | // settings = RouteSettings(name: name, arguments: Get.arguments); |
87 | 87 | ||
@@ -96,7 +96,8 @@ class GetPage<T> extends Page<T> { | @@ -96,7 +96,8 @@ class GetPage<T> extends Page<T> { | ||
96 | Alignment? alignment, | 96 | Alignment? alignment, |
97 | bool? maintainState, | 97 | bool? maintainState, |
98 | bool? opaque, | 98 | bool? opaque, |
99 | - BindingsInterface? binding, | 99 | + List<BindingsInterface>? bindings, |
100 | + // BindingsInterface? binding, | ||
100 | List<Bind>? binds, | 101 | List<Bind>? binds, |
101 | CustomTransition? customTransition, | 102 | CustomTransition? customTransition, |
102 | Duration? transitionDuration, | 103 | Duration? transitionDuration, |
@@ -126,7 +127,7 @@ class GetPage<T> extends Page<T> { | @@ -126,7 +127,7 @@ class GetPage<T> extends Page<T> { | ||
126 | alignment: alignment ?? this.alignment, | 127 | alignment: alignment ?? this.alignment, |
127 | maintainState: maintainState ?? this.maintainState, | 128 | maintainState: maintainState ?? this.maintainState, |
128 | opaque: opaque ?? this.opaque, | 129 | opaque: opaque ?? this.opaque, |
129 | - binding: binding ?? this.binding, | 130 | + bindings: bindings ?? this.bindings, |
130 | binds: binds ?? this.binds, | 131 | binds: binds ?? this.binds, |
131 | customTransition: customTransition ?? this.customTransition, | 132 | customTransition: customTransition ?? this.customTransition, |
132 | transitionDuration: transitionDuration ?? this.transitionDuration, | 133 | transitionDuration: transitionDuration ?? this.transitionDuration, |
@@ -3,7 +3,7 @@ import 'dart:async'; | @@ -3,7 +3,7 @@ import 'dart:async'; | ||
3 | import 'package:flutter/foundation.dart'; | 3 | import 'package:flutter/foundation.dart'; |
4 | import 'package:flutter/material.dart'; | 4 | import 'package:flutter/material.dart'; |
5 | 5 | ||
6 | -import '../../../get_state_manager/src/simple/get_state.dart'; | 6 | +import '../../../get_instance/src/bindings_interface.dart'; |
7 | import '../../../get_state_manager/src/simple/list_notifier.dart'; | 7 | import '../../../get_state_manager/src/simple/list_notifier.dart'; |
8 | import '../../../get_utils/src/platform/platform.dart'; | 8 | import '../../../get_utils/src/platform/platform.dart'; |
9 | import '../../../route_manager.dart'; | 9 | import '../../../route_manager.dart'; |
@@ -107,7 +107,7 @@ class GetDelegate extends RouterDelegate<RouteDecoder> | @@ -107,7 +107,7 @@ class GetDelegate extends RouterDelegate<RouteDecoder> | ||
107 | } | 107 | } |
108 | var iterator = config; | 108 | var iterator = config; |
109 | for (var item in middlewares) { | 109 | for (var item in middlewares) { |
110 | - var redirectRes = await item.redirectDelegate(iterator); | 110 | + var redirectRes = await item.redirect(iterator); |
111 | if (redirectRes == null) return null; | 111 | if (redirectRes == null) return null; |
112 | iterator = redirectRes; | 112 | iterator = redirectRes; |
113 | } | 113 | } |
@@ -141,15 +141,15 @@ class GetDelegate extends RouterDelegate<RouteDecoder> | @@ -141,15 +141,15 @@ class GetDelegate extends RouterDelegate<RouteDecoder> | ||
141 | } | 141 | } |
142 | 142 | ||
143 | T arguments<T>() { | 143 | T arguments<T>() { |
144 | - return currentConfiguration?.arguments?.arguments as T; | 144 | + return currentConfiguration?.pageSettings?.arguments as T; |
145 | } | 145 | } |
146 | 146 | ||
147 | Map<String, String> get parameters { | 147 | Map<String, String> get parameters { |
148 | - return currentConfiguration?.arguments?.params ?? {}; | 148 | + return currentConfiguration?.pageSettings?.params ?? {}; |
149 | } | 149 | } |
150 | 150 | ||
151 | PageSettings? get pageSettings { | 151 | PageSettings? get pageSettings { |
152 | - return currentConfiguration?.arguments; | 152 | + return currentConfiguration?.pageSettings; |
153 | } | 153 | } |
154 | 154 | ||
155 | Future<T?> _removeHistoryEntry<T>(RouteDecoder entry, T result) async { | 155 | Future<T?> _removeHistoryEntry<T>(RouteDecoder entry, T result) async { |
@@ -159,11 +159,11 @@ class GetDelegate extends RouterDelegate<RouteDecoder> | @@ -159,11 +159,11 @@ class GetDelegate extends RouterDelegate<RouteDecoder> | ||
159 | Future<void> _pushHistory(RouteDecoder config) async { | 159 | Future<void> _pushHistory(RouteDecoder config) async { |
160 | if (config.route!.preventDuplicates) { | 160 | if (config.route!.preventDuplicates) { |
161 | final originalEntryIndex = _activePages.indexWhere( | 161 | final originalEntryIndex = _activePages.indexWhere( |
162 | - (element) => element.arguments?.name == config.arguments?.name); | 162 | + (element) => element.pageSettings?.name == config.pageSettings?.name); |
163 | if (originalEntryIndex >= 0) { | 163 | if (originalEntryIndex >= 0) { |
164 | switch (preventDuplicateHandlingMode) { | 164 | switch (preventDuplicateHandlingMode) { |
165 | case PreventDuplicateHandlingMode.PopUntilOriginalRoute: | 165 | case PreventDuplicateHandlingMode.PopUntilOriginalRoute: |
166 | - popModeUntil(config.arguments!.name, popMode: PopMode.Page); | 166 | + popModeUntil(config.pageSettings!.name, popMode: PopMode.Page); |
167 | break; | 167 | break; |
168 | case PreventDuplicateHandlingMode.ReorderRoutes: | 168 | case PreventDuplicateHandlingMode.ReorderRoutes: |
169 | await _unsafeHistoryRemoveAt(originalEntryIndex, null); | 169 | await _unsafeHistoryRemoveAt(originalEntryIndex, null); |
@@ -207,7 +207,7 @@ class GetDelegate extends RouterDelegate<RouteDecoder> | @@ -207,7 +207,7 @@ class GetDelegate extends RouterDelegate<RouteDecoder> | ||
207 | if (prevHistoryEntry != null) { | 207 | if (prevHistoryEntry != null) { |
208 | //if so, pop the entire _activePages entry | 208 | //if so, pop the entire _activePages entry |
209 | final newLocation = remaining.last.name; | 209 | final newLocation = remaining.last.name; |
210 | - final prevLocation = prevHistoryEntry.arguments?.name; | 210 | + final prevLocation = prevHistoryEntry.pageSettings?.name; |
211 | if (newLocation == prevLocation) { | 211 | if (newLocation == prevLocation) { |
212 | //pop the entire _activePages entry | 212 | //pop the entire _activePages entry |
213 | return await _popHistory(result); | 213 | return await _popHistory(result); |
@@ -301,10 +301,7 @@ class GetDelegate extends RouterDelegate<RouteDecoder> | @@ -301,10 +301,7 @@ class GetDelegate extends RouterDelegate<RouteDecoder> | ||
301 | key: navigatorKey, | 301 | key: navigatorKey, |
302 | onPopPage: _onPopVisualRoute, | 302 | onPopPage: _onPopVisualRoute, |
303 | pages: pages.toList(), | 303 | pages: pages.toList(), |
304 | - observers: [ | ||
305 | - GetObserver(), | ||
306 | - ...?navigatorObservers, | ||
307 | - ], | 304 | + observers: navigatorObservers, |
308 | transitionDelegate: | 305 | transitionDelegate: |
309 | transitionDelegate ?? const DefaultTransitionDelegate<dynamic>(), | 306 | transitionDelegate ?? const DefaultTransitionDelegate<dynamic>(), |
310 | ); | 307 | ); |
@@ -353,7 +350,7 @@ class GetDelegate extends RouterDelegate<RouteDecoder> | @@ -353,7 +350,7 @@ class GetDelegate extends RouterDelegate<RouteDecoder> | ||
353 | String? routeName, | 350 | String? routeName, |
354 | bool fullscreenDialog = false, | 351 | bool fullscreenDialog = false, |
355 | dynamic arguments, | 352 | dynamic arguments, |
356 | - Binding? binding, | 353 | + List<BindingsInterface>? bindings, |
357 | bool preventDuplicates = true, | 354 | bool preventDuplicates = true, |
358 | bool? popGesture, | 355 | bool? popGesture, |
359 | bool showCupertinoParallax = true, | 356 | bool showCupertinoParallax = true, |
@@ -376,7 +373,7 @@ class GetDelegate extends RouterDelegate<RouteDecoder> | @@ -376,7 +373,7 @@ class GetDelegate extends RouterDelegate<RouteDecoder> | ||
376 | transition: transition ?? Get.defaultTransition, | 373 | transition: transition ?? Get.defaultTransition, |
377 | curve: curve ?? Get.defaultTransitionCurve, | 374 | curve: curve ?? Get.defaultTransitionCurve, |
378 | fullscreenDialog: fullscreenDialog, | 375 | fullscreenDialog: fullscreenDialog, |
379 | - binding: binding, | 376 | + bindings: bindings, |
380 | transitionDuration: duration ?? Get.defaultTransitionDuration, | 377 | transitionDuration: duration ?? Get.defaultTransitionDuration, |
381 | preventDuplicateHandlingMode: preventDuplicateHandlingMode, | 378 | preventDuplicateHandlingMode: preventDuplicateHandlingMode, |
382 | ); | 379 | ); |
@@ -404,7 +401,7 @@ class GetDelegate extends RouterDelegate<RouteDecoder> | @@ -404,7 +401,7 @@ class GetDelegate extends RouterDelegate<RouteDecoder> | ||
404 | String? routeName, | 401 | String? routeName, |
405 | bool fullscreenDialog = false, | 402 | bool fullscreenDialog = false, |
406 | dynamic arguments, | 403 | dynamic arguments, |
407 | - Binding? binding, | 404 | + List<BindingsInterface>? bindings, |
408 | bool preventDuplicates = true, | 405 | bool preventDuplicates = true, |
409 | bool? popGesture, | 406 | bool? popGesture, |
410 | bool showCupertinoParallax = true, | 407 | bool showCupertinoParallax = true, |
@@ -421,7 +418,7 @@ class GetDelegate extends RouterDelegate<RouteDecoder> | @@ -421,7 +418,7 @@ class GetDelegate extends RouterDelegate<RouteDecoder> | ||
421 | transition: transition ?? Get.defaultTransition, | 418 | transition: transition ?? Get.defaultTransition, |
422 | curve: curve ?? Get.defaultTransitionCurve, | 419 | curve: curve ?? Get.defaultTransitionCurve, |
423 | fullscreenDialog: fullscreenDialog, | 420 | fullscreenDialog: fullscreenDialog, |
424 | - binding: binding, | 421 | + bindings: bindings, |
425 | transitionDuration: duration ?? Get.defaultTransitionDuration, | 422 | transitionDuration: duration ?? Get.defaultTransitionDuration, |
426 | ); | 423 | ); |
427 | 424 | ||
@@ -438,7 +435,7 @@ class GetDelegate extends RouterDelegate<RouteDecoder> | @@ -438,7 +435,7 @@ class GetDelegate extends RouterDelegate<RouteDecoder> | ||
438 | int? id, | 435 | int? id, |
439 | String? routeName, | 436 | String? routeName, |
440 | dynamic arguments, | 437 | dynamic arguments, |
441 | - Binding? binding, | 438 | + List<BindingsInterface>? bindings, |
442 | bool fullscreenDialog = false, | 439 | bool fullscreenDialog = false, |
443 | Transition? transition, | 440 | Transition? transition, |
444 | Curve? curve, | 441 | Curve? curve, |
@@ -457,7 +454,7 @@ class GetDelegate extends RouterDelegate<RouteDecoder> | @@ -457,7 +454,7 @@ class GetDelegate extends RouterDelegate<RouteDecoder> | ||
457 | transition: transition ?? Get.defaultTransition, | 454 | transition: transition ?? Get.defaultTransition, |
458 | curve: curve ?? Get.defaultTransitionCurve, | 455 | curve: curve ?? Get.defaultTransitionCurve, |
459 | fullscreenDialog: fullscreenDialog, | 456 | fullscreenDialog: fullscreenDialog, |
460 | - binding: binding, | 457 | + bindings: bindings, |
461 | transitionDuration: duration ?? Get.defaultTransitionDuration, | 458 | transitionDuration: duration ?? Get.defaultTransitionDuration, |
462 | ); | 459 | ); |
463 | 460 | ||
@@ -607,7 +604,7 @@ class GetDelegate extends RouterDelegate<RouteDecoder> | @@ -607,7 +604,7 @@ class GetDelegate extends RouterDelegate<RouteDecoder> | ||
607 | var iterator = currentConfiguration; | 604 | var iterator = currentConfiguration; |
608 | while (_canPop(popMode) && | 605 | while (_canPop(popMode) && |
609 | iterator != null && | 606 | iterator != null && |
610 | - iterator.arguments?.name != fullRoute) { | 607 | + iterator.pageSettings?.name != fullRoute) { |
611 | await _pop(popMode, null); | 608 | await _pop(popMode, null); |
612 | // replace iterator | 609 | // replace iterator |
613 | iterator = currentConfiguration; | 610 | iterator = currentConfiguration; |
@@ -98,7 +98,7 @@ class GetObserver extends NavigatorObserver { | @@ -98,7 +98,7 @@ class GetObserver extends NavigatorObserver { | ||
98 | } | 98 | } |
99 | 99 | ||
100 | RouterReportManager.instance.reportCurrentRoute(route); | 100 | RouterReportManager.instance.reportCurrentRoute(route); |
101 | - _routeSend?.update((value) { | 101 | + _routeSend!.update((value) { |
102 | // Only PageRoute is allowed to change current value | 102 | // Only PageRoute is allowed to change current value |
103 | if (route is PageRoute) { | 103 | if (route is PageRoute) { |
104 | value.current = newRoute.name ?? ''; | 104 | value.current = newRoute.name ?? ''; |
1 | import '../../../route_manager.dart'; | 1 | import '../../../route_manager.dart'; |
2 | -import 'page_settings.dart'; | ||
3 | 2 | ||
4 | class RouteDecoder { | 3 | class RouteDecoder { |
5 | const RouteDecoder( | 4 | const RouteDecoder( |
6 | this.currentTreeBranch, | 5 | this.currentTreeBranch, |
7 | - this.arguments, | 6 | + this.pageSettings, |
8 | ); | 7 | ); |
9 | final List<GetPage> currentTreeBranch; | 8 | final List<GetPage> currentTreeBranch; |
10 | - final PageSettings? arguments; | 9 | + final PageSettings? pageSettings; |
11 | 10 | ||
12 | factory RouteDecoder.fromRoute(String location) { | 11 | factory RouteDecoder.fromRoute(String location) { |
13 | var uri = Uri.parse(location); | 12 | var uri = Uri.parse(location); |
@@ -38,7 +37,20 @@ class RouteDecoder { | @@ -38,7 +37,20 @@ class RouteDecoder { | ||
38 | 37 | ||
39 | List<GetPage>? get currentChildrens => route?.children; | 38 | List<GetPage>? get currentChildrens => route?.children; |
40 | 39 | ||
41 | - Map<String, String> get parameters => arguments?.params ?? {}; | 40 | + Map<String, String> get parameters => pageSettings?.params ?? {}; |
41 | + | ||
42 | + dynamic get args { | ||
43 | + return pageSettings?.arguments; | ||
44 | + } | ||
45 | + | ||
46 | + T? arguments<T>() { | ||
47 | + final args = pageSettings?.arguments; | ||
48 | + if (args is T) { | ||
49 | + return pageSettings?.arguments as T; | ||
50 | + } else { | ||
51 | + return null; | ||
52 | + } | ||
53 | + } | ||
42 | 54 | ||
43 | void replaceArguments(Object? arguments) { | 55 | void replaceArguments(Object? arguments) { |
44 | final _route = route; | 56 | final _route = route; |
@@ -20,21 +20,6 @@ abstract class _RouteMiddleware { | @@ -20,21 +20,6 @@ abstract class _RouteMiddleware { | ||
20 | /// {@end-tool} | 20 | /// {@end-tool} |
21 | int? priority; | 21 | int? priority; |
22 | 22 | ||
23 | - /// This function will be called when the page of | ||
24 | - /// the called route is being searched for. | ||
25 | - /// It take RouteSettings as a result an redirect to the new settings or | ||
26 | - /// give it null and there will be no redirecting. | ||
27 | - /// {@tool snippet} | ||
28 | - /// ```dart | ||
29 | - /// GetPage redirect(String route) { | ||
30 | - /// final authService = Get.find<AuthService>(); | ||
31 | - /// return authService.authed.value ? null : RouteSettings(name: '/login'); | ||
32 | - /// } | ||
33 | - /// ``` | ||
34 | - /// {@end-tool} | ||
35 | - RouteSettings? redirect(String route); | ||
36 | - | ||
37 | - /// Similar to [redirect], | ||
38 | /// This function will be called when the router delegate changes the | 23 | /// This function will be called when the router delegate changes the |
39 | /// current route. | 24 | /// current route. |
40 | /// | 25 | /// |
@@ -45,13 +30,13 @@ abstract class _RouteMiddleware { | @@ -45,13 +30,13 @@ abstract class _RouteMiddleware { | ||
45 | /// and no new routes are pushed. | 30 | /// and no new routes are pushed. |
46 | /// {@tool snippet} | 31 | /// {@tool snippet} |
47 | /// ```dart | 32 | /// ```dart |
48 | - /// GetNavConfig? redirect(GetNavConfig route) { | 33 | + /// RouteDecoder? redirect(RouteDecoder route) { |
49 | /// final authService = Get.find<AuthService>(); | 34 | /// final authService = Get.find<AuthService>(); |
50 | - /// return authService.authed.value ? null : RouteSettings(name: '/login'); | 35 | + /// return authService.authed.value ? null : RouteDecoder.fromRoute('/login'); |
51 | /// } | 36 | /// } |
52 | /// ``` | 37 | /// ``` |
53 | /// {@end-tool} | 38 | /// {@end-tool} |
54 | - Future<RouteDecoder?> redirectDelegate(RouteDecoder route); | 39 | + Future<RouteDecoder?> redirect(RouteDecoder route); |
55 | 40 | ||
56 | /// This function will be called when this Page is called | 41 | /// This function will be called when this Page is called |
57 | /// you can use it to change something about the page or give it new page | 42 | /// you can use it to change something about the page or give it new page |
@@ -101,8 +86,8 @@ class GetMiddleware implements _RouteMiddleware { | @@ -101,8 +86,8 @@ class GetMiddleware implements _RouteMiddleware { | ||
101 | 86 | ||
102 | GetMiddleware({this.priority}); | 87 | GetMiddleware({this.priority}); |
103 | 88 | ||
104 | - @override | ||
105 | - RouteSettings? redirect(String? route) => null; | 89 | + // @override |
90 | + // RouteSettings? redirect(String? route) => null; | ||
106 | 91 | ||
107 | @override | 92 | @override |
108 | GetPage? onPageCalled(GetPage? page) => page; | 93 | GetPage? onPageCalled(GetPage? page) => page; |
@@ -120,7 +105,7 @@ class GetMiddleware implements _RouteMiddleware { | @@ -120,7 +105,7 @@ class GetMiddleware implements _RouteMiddleware { | ||
120 | void onPageDispose() {} | 105 | void onPageDispose() {} |
121 | 106 | ||
122 | @override | 107 | @override |
123 | - Future<RouteDecoder?> redirectDelegate(RouteDecoder route) => | 108 | + Future<RouteDecoder?> redirect(RouteDecoder route) => |
124 | SynchronousFuture(route); | 109 | SynchronousFuture(route); |
125 | } | 110 | } |
126 | 111 | ||
@@ -144,17 +129,17 @@ class MiddlewareRunner { | @@ -144,17 +129,17 @@ class MiddlewareRunner { | ||
144 | return page; | 129 | return page; |
145 | } | 130 | } |
146 | 131 | ||
147 | - RouteSettings? runRedirect(String? route) { | ||
148 | - RouteSettings? to; | ||
149 | - for (final element in _getMiddlewares()) { | ||
150 | - to = element.redirect(route); | ||
151 | - if (to != null) { | ||
152 | - break; | ||
153 | - } | ||
154 | - } | ||
155 | - Get.log('Redirect to $to'); | ||
156 | - return to; | ||
157 | - } | 132 | + // RouteSettings? runRedirect(String? route) { |
133 | + // RouteSettings? to; | ||
134 | + // for (final element in _getMiddlewares()) { | ||
135 | + // to = element.redirect(route); | ||
136 | + // if (to != null) { | ||
137 | + // break; | ||
138 | + // } | ||
139 | + // } | ||
140 | + // Get.log('Redirect to $to'); | ||
141 | + // return to; | ||
142 | + // } | ||
158 | 143 | ||
159 | List<R>? runOnBindingsStart<R>(List<R>? bindings) { | 144 | List<R>? runOnBindingsStart<R>(List<R>? bindings) { |
160 | _getMiddlewares().forEach((element) { | 145 | _getMiddlewares().forEach((element) { |
@@ -212,7 +197,7 @@ class PageRedirect { | @@ -212,7 +197,7 @@ class PageRedirect { | ||
212 | showCupertinoParallax: _r.showCupertinoParallax, | 197 | showCupertinoParallax: _r.showCupertinoParallax, |
213 | gestureWidth: _r.gestureWidth, | 198 | gestureWidth: _r.gestureWidth, |
214 | customTransition: _r.customTransition, | 199 | customTransition: _r.customTransition, |
215 | - binding: _r.binding, | 200 | + bindings: _r.bindings, |
216 | binds: _r.binds, | 201 | binds: _r.binds, |
217 | transitionDuration: | 202 | transitionDuration: |
218 | _r.transitionDuration ?? Get.defaultTransitionDuration, | 203 | _r.transitionDuration ?? Get.defaultTransitionDuration, |
@@ -235,13 +220,13 @@ class PageRedirect { | @@ -235,13 +220,13 @@ class PageRedirect { | ||
235 | title: _r.title, | 220 | title: _r.title, |
236 | maintainState: _r.maintainState, | 221 | maintainState: _r.maintainState, |
237 | routeName: _r.name, | 222 | routeName: _r.name, |
238 | - settings: _r, | 223 | + settings: settings, |
239 | curve: _r.curve, | 224 | curve: _r.curve, |
240 | showCupertinoParallax: _r.showCupertinoParallax, | 225 | showCupertinoParallax: _r.showCupertinoParallax, |
241 | gestureWidth: _r.gestureWidth, | 226 | gestureWidth: _r.gestureWidth, |
242 | opaque: _r.opaque, | 227 | opaque: _r.opaque, |
243 | customTransition: _r.customTransition, | 228 | customTransition: _r.customTransition, |
244 | - binding: _r.binding, | 229 | + bindings: _r.bindings, |
245 | binds: _r.binds, | 230 | binds: _r.binds, |
246 | transitionDuration: | 231 | transitionDuration: |
247 | _r.transitionDuration ?? Get.defaultTransitionDuration, | 232 | _r.transitionDuration ?? Get.defaultTransitionDuration, |
@@ -274,11 +259,11 @@ class PageRedirect { | @@ -274,11 +259,11 @@ class PageRedirect { | ||
274 | if (match.route!.middlewares == null || match.route!.middlewares!.isEmpty) { | 259 | if (match.route!.middlewares == null || match.route!.middlewares!.isEmpty) { |
275 | return false; | 260 | return false; |
276 | } | 261 | } |
277 | - final newSettings = runner.runRedirect(settings!.name); | ||
278 | - if (newSettings == null) { | ||
279 | - return false; | ||
280 | - } | ||
281 | - settings = newSettings; | 262 | + // final newSettings = runner.runRedirect(settings!.name); |
263 | + // if (newSettings == null) { | ||
264 | + // return false; | ||
265 | + // } | ||
266 | + // settings = newSettings; | ||
282 | return true; | 267 | return true; |
283 | } | 268 | } |
284 | 269 |
@@ -137,7 +137,7 @@ class GetRouterOutlet extends RouterOutlet<GetDelegate, RouteDecoder> { | @@ -137,7 +137,7 @@ class GetRouterOutlet extends RouterOutlet<GetDelegate, RouteDecoder> { | ||
137 | return (emptyWidget?.call(rDelegate) ?? SizedBox.shrink()); | 137 | return (emptyWidget?.call(rDelegate) ?? SizedBox.shrink()); |
138 | }, | 138 | }, |
139 | pickPages: pickPages, | 139 | pickPages: pickPages, |
140 | - delegate: delegate ?? Get.rootController.rootDelegate, | 140 | + delegate: delegate ?? GetMaterialController.to.rootDelegate, |
141 | ); | 141 | ); |
142 | 142 | ||
143 | GetRouterOutlet.builder({ | 143 | GetRouterOutlet.builder({ |
@@ -154,16 +154,18 @@ extension ListExtension<E> on List<E> { | @@ -154,16 +154,18 @@ extension ListExtension<E> on List<E> { | ||
154 | // (this as RxList)._value; | 154 | // (this as RxList)._value; |
155 | // } | 155 | // } |
156 | 156 | ||
157 | - clear(); | 157 | + if (this is RxList) { |
158 | + (this as RxList).value.clear(); | ||
159 | + } | ||
158 | add(item); | 160 | add(item); |
159 | } | 161 | } |
160 | 162 | ||
161 | /// Replaces all existing items of this list with [items] | 163 | /// Replaces all existing items of this list with [items] |
162 | void assignAll(Iterable<E> items) { | 164 | void assignAll(Iterable<E> items) { |
163 | - // if (this is RxList) { | ||
164 | - // (this as RxList)._value; | ||
165 | - // } | ||
166 | - clear(); | 165 | + if (this is RxList) { |
166 | + (this as RxList).value.clear(); | ||
167 | + } | ||
168 | + //clear(); | ||
167 | addAll(items); | 169 | addAll(items); |
168 | } | 170 | } |
169 | } | 171 | } |
@@ -26,25 +26,25 @@ extension _Empty on Object { | @@ -26,25 +26,25 @@ extension _Empty on Object { | ||
26 | 26 | ||
27 | mixin StateMixin<T> on ListNotifier { | 27 | mixin StateMixin<T> on ListNotifier { |
28 | late T _value; | 28 | late T _value; |
29 | - GetState<T>? _status; | 29 | + GetStatus<T>? _status; |
30 | 30 | ||
31 | void _fillInitialStatus() { | 31 | void _fillInitialStatus() { |
32 | _status = (value == null || value!._isEmpty()) | 32 | _status = (value == null || value!._isEmpty()) |
33 | - ? GetState<T>.loading() | ||
34 | - : GetState<T>.success(_value); | 33 | + ? GetStatus<T>.loading() |
34 | + : GetStatus<T>.success(_value); | ||
35 | } | 35 | } |
36 | 36 | ||
37 | - GetState<T> get status { | 37 | + GetStatus<T> get status { |
38 | reportRead(); | 38 | reportRead(); |
39 | - return _status ??= _status = GetState.loading(); | 39 | + return _status ??= _status = GetStatus.loading(); |
40 | } | 40 | } |
41 | 41 | ||
42 | T get state => value; | 42 | T get state => value; |
43 | 43 | ||
44 | - set status(GetState<T> newStatus) { | 44 | + set status(GetStatus<T> newStatus) { |
45 | if (newStatus == status) return; | 45 | if (newStatus == status) return; |
46 | _status = newStatus; | 46 | _status = newStatus; |
47 | - if (newStatus is SuccessState<T>) { | 47 | + if (newStatus is SuccessStatus<T>) { |
48 | _value = newStatus.data!; | 48 | _value = newStatus.data!; |
49 | return; | 49 | return; |
50 | } | 50 | } |
@@ -69,14 +69,14 @@ mixin StateMixin<T> on ListNotifier { | @@ -69,14 +69,14 @@ mixin StateMixin<T> on ListNotifier { | ||
69 | final compute = body(); | 69 | final compute = body(); |
70 | compute().then((newValue) { | 70 | compute().then((newValue) { |
71 | if ((newValue == null || newValue._isEmpty()) && useEmpty) { | 71 | if ((newValue == null || newValue._isEmpty()) && useEmpty) { |
72 | - status = GetState<T>.loading(); | 72 | + status = GetStatus<T>.loading(); |
73 | } else { | 73 | } else { |
74 | - status = GetState<T>.success(newValue); | 74 | + status = GetStatus<T>.success(newValue); |
75 | } | 75 | } |
76 | 76 | ||
77 | refresh(); | 77 | refresh(); |
78 | }, onError: (err) { | 78 | }, onError: (err) { |
79 | - status = GetState.error(errorMessage ?? err.toString()); | 79 | + status = GetStatus.error(errorMessage ?? err.toString()); |
80 | refresh(); | 80 | refresh(); |
81 | }); | 81 | }); |
82 | } | 82 | } |
@@ -91,6 +91,8 @@ class GetListenable<T> extends ListNotifierSingle implements RxInterface<T> { | @@ -91,6 +91,8 @@ class GetListenable<T> extends ListNotifierSingle implements RxInterface<T> { | ||
91 | if (_controller == null) { | 91 | if (_controller == null) { |
92 | _controller = StreamController<T>.broadcast(); | 92 | _controller = StreamController<T>.broadcast(); |
93 | addListener(_streamListener); | 93 | addListener(_streamListener); |
94 | + | ||
95 | + ///TODO: report to controller dispose | ||
94 | } | 96 | } |
95 | return _controller!; | 97 | return _controller!; |
96 | } | 98 | } |
@@ -231,39 +233,39 @@ extension StateExt<T> on StateMixin<T> { | @@ -231,39 +233,39 @@ extension StateExt<T> on StateMixin<T> { | ||
231 | 233 | ||
232 | typedef NotifierBuilder<T> = Widget Function(T state); | 234 | typedef NotifierBuilder<T> = Widget Function(T state); |
233 | 235 | ||
234 | -abstract class GetState<T> { | ||
235 | - const GetState(); | ||
236 | - factory GetState.loading() => LoadingState(); | ||
237 | - factory GetState.error(String message) => ErrorState(message); | ||
238 | - factory GetState.empty() => EmptyState(); | ||
239 | - factory GetState.success(T data) => SuccessState(data); | 236 | +abstract class GetStatus<T> { |
237 | + const GetStatus(); | ||
238 | + factory GetStatus.loading() => LoadingStatus(); | ||
239 | + factory GetStatus.error(String message) => ErrorStatus(message); | ||
240 | + factory GetStatus.empty() => EmptyStatus(); | ||
241 | + factory GetStatus.success(T data) => SuccessStatus(data); | ||
240 | } | 242 | } |
241 | 243 | ||
242 | -class LoadingState<T> extends GetState<T> {} | 244 | +class LoadingStatus<T> extends GetStatus<T> {} |
243 | 245 | ||
244 | -class SuccessState<T> extends GetState<T> { | 246 | +class SuccessStatus<T> extends GetStatus<T> { |
245 | final T data; | 247 | final T data; |
246 | 248 | ||
247 | - SuccessState(this.data); | 249 | + SuccessStatus(this.data); |
248 | } | 250 | } |
249 | 251 | ||
250 | -class ErrorState<T, S> extends GetState<T> { | 252 | +class ErrorStatus<T, S> extends GetStatus<T> { |
251 | final S? error; | 253 | final S? error; |
252 | - ErrorState([this.error]); | 254 | + ErrorStatus([this.error]); |
253 | } | 255 | } |
254 | 256 | ||
255 | -class EmptyState<T> extends GetState<T> {} | 257 | +class EmptyStatus<T> extends GetStatus<T> {} |
256 | 258 | ||
257 | -extension StatusDataExt<T> on GetState<T> { | ||
258 | - bool get isLoading => this is LoadingState; | ||
259 | - bool get isSuccess => this is SuccessState; | ||
260 | - bool get isError => this is ErrorState; | ||
261 | - bool get isEmpty => this is EmptyState; | 259 | +extension StatusDataExt<T> on GetStatus<T> { |
260 | + bool get isLoading => this is LoadingStatus; | ||
261 | + bool get isSuccess => this is SuccessStatus; | ||
262 | + bool get isError => this is ErrorStatus; | ||
263 | + bool get isEmpty => this is EmptyStatus; | ||
262 | bool get isCustom => !isLoading && !isSuccess && !isError && !isEmpty; | 264 | bool get isCustom => !isLoading && !isSuccess && !isError && !isEmpty; |
263 | String get errorMessage { | 265 | String get errorMessage { |
264 | - final isError = this is ErrorState; | 266 | + final isError = this is ErrorStatus; |
265 | if (isError) { | 267 | if (isError) { |
266 | - final err = this as ErrorState; | 268 | + final err = this as ErrorStatus; |
267 | if (err.error != null && err.error is String) { | 269 | if (err.error != null && err.error is String) { |
268 | return err.error as String; | 270 | return err.error as String; |
269 | } | 271 | } |
@@ -273,8 +275,8 @@ extension StatusDataExt<T> on GetState<T> { | @@ -273,8 +275,8 @@ extension StatusDataExt<T> on GetState<T> { | ||
273 | } | 275 | } |
274 | 276 | ||
275 | T? get data { | 277 | T? get data { |
276 | - if (this is SuccessState<T>) { | ||
277 | - final success = this as SuccessState<T>; | 278 | + if (this is SuccessStatus<T>) { |
279 | + final success = this as SuccessStatus<T>; | ||
278 | return success.data; | 280 | return success.data; |
279 | } | 281 | } |
280 | return null; | 282 | return null; |
@@ -21,7 +21,7 @@ class ListNotifierGroup = ListNotifier with ListNotifierGroupMixin; | @@ -21,7 +21,7 @@ class ListNotifierGroup = ListNotifier with ListNotifierGroupMixin; | ||
21 | /// This mixin add to Listenable the addListener, removerListener and | 21 | /// This mixin add to Listenable the addListener, removerListener and |
22 | /// containsListener implementation | 22 | /// containsListener implementation |
23 | mixin ListNotifierSingleMixin on Listenable { | 23 | mixin ListNotifierSingleMixin on Listenable { |
24 | - List<GetStateUpdate?>? _updaters = <GetStateUpdate?>[]; | 24 | + List<GetStateUpdate>? _updaters = <GetStateUpdate>[]; |
25 | 25 | ||
26 | @override | 26 | @override |
27 | Disposer addListener(GetStateUpdate listener) { | 27 | Disposer addListener(GetStateUpdate listener) { |
@@ -57,8 +57,9 @@ mixin ListNotifierSingleMixin on Listenable { | @@ -57,8 +57,9 @@ mixin ListNotifierSingleMixin on Listenable { | ||
57 | } | 57 | } |
58 | 58 | ||
59 | void _notifyUpdate() { | 59 | void _notifyUpdate() { |
60 | - for (var element in _updaters!) { | ||
61 | - element!(); | 60 | + final list = _updaters?.toList() ?? []; |
61 | + for (var element in list) { | ||
62 | + element(); | ||
62 | } | 63 | } |
63 | } | 64 | } |
64 | 65 |
1 | import 'dart:async'; | 1 | import 'dart:async'; |
2 | 2 | ||
3 | +import 'package:flutter/scheduler.dart'; | ||
3 | import 'package:flutter/widgets.dart'; | 4 | import 'package:flutter/widgets.dart'; |
4 | 5 | ||
5 | import 'list_notifier.dart'; | 6 | import 'list_notifier.dart'; |
@@ -95,8 +96,26 @@ mixin ObserverComponent on ComponentElement { | @@ -95,8 +96,26 @@ mixin ObserverComponent on ComponentElement { | ||
95 | 96 | ||
96 | void getUpdate() { | 97 | void getUpdate() { |
97 | if (disposers != null) { | 98 | if (disposers != null) { |
99 | + _safeRebuild(); | ||
100 | + } | ||
101 | + } | ||
102 | + | ||
103 | + Future<bool> _safeRebuild() async { | ||
104 | + if (dirty) return false; | ||
105 | + if (SchedulerBinding.instance == null) { | ||
98 | markNeedsBuild(); | 106 | markNeedsBuild(); |
107 | + } else { | ||
108 | + // refresh was called during the building | ||
109 | + if (SchedulerBinding.instance!.schedulerPhase != SchedulerPhase.idle) { | ||
110 | + // Await for the end of build | ||
111 | + await SchedulerBinding.instance!.endOfFrame; | ||
112 | + if (dirty) return false; | ||
99 | } | 113 | } |
114 | + | ||
115 | + markNeedsBuild(); | ||
116 | + } | ||
117 | + | ||
118 | + return true; | ||
100 | } | 119 | } |
101 | 120 | ||
102 | @override | 121 | @override |
1 | -import 'package:collection/collection.dart'; | ||
2 | import 'package:flutter/material.dart'; | 1 | import 'package:flutter/material.dart'; |
3 | 2 | ||
4 | extension ContextExt on BuildContext { | 3 | extension ContextExt on BuildContext { |
@@ -170,3 +169,12 @@ extension ContextExt on BuildContext { | @@ -170,3 +169,12 @@ extension ContextExt on BuildContext { | ||
170 | return strictValues.firstOrNull ?? looseValues.first; | 169 | return strictValues.firstOrNull ?? looseValues.first; |
171 | } | 170 | } |
172 | } | 171 | } |
172 | + | ||
173 | +extension IterableExt<T> on Iterable<T> { | ||
174 | + /// The first element, or `null` if the iterable is empty. | ||
175 | + T? get firstOrNull { | ||
176 | + var iterator = this.iterator; | ||
177 | + if (iterator.moveNext()) return iterator.current; | ||
178 | + return null; | ||
179 | + } | ||
180 | +} |
1 | name: get | 1 | name: get |
2 | description: Open screens/snackbars/dialogs without context, manage states and inject dependencies easily with GetX. | 2 | description: Open screens/snackbars/dialogs without context, manage states and inject dependencies easily with GetX. |
3 | -version: 4.6.1 | 3 | +version: 5.0.0-beta.14 |
4 | homepage: https://github.com/jonataslaw/getx | 4 | homepage: https://github.com/jonataslaw/getx |
5 | 5 | ||
6 | environment: | 6 | environment: |
7 | - sdk: '>=2.12.0 <3.0.0' | 7 | + sdk: '>=2.13.0 <3.0.0' |
8 | 8 | ||
9 | dependencies: | 9 | dependencies: |
10 | flutter: | 10 | flutter: |
@@ -48,9 +48,13 @@ void main() { | @@ -48,9 +48,13 @@ void main() { | ||
48 | ), | 48 | ), |
49 | )); | 49 | )); |
50 | 50 | ||
51 | + await tester.pumpAndSettle(); | ||
52 | + | ||
51 | expect(Get.isBottomSheetOpen, true); | 53 | expect(Get.isBottomSheetOpen, true); |
52 | 54 | ||
53 | Get.back(); | 55 | Get.back(); |
56 | + await tester.pumpAndSettle(); | ||
57 | + | ||
54 | expect(Get.isBottomSheetOpen, false); | 58 | expect(Get.isBottomSheetOpen, false); |
55 | 59 | ||
56 | // expect(() => Get.bottomSheet(Container(), isScrollControlled: null), | 60 | // expect(() => Get.bottomSheet(Container(), isScrollControlled: null), |
@@ -51,7 +51,7 @@ void main() { | @@ -51,7 +51,7 @@ void main() { | ||
51 | Get.back(); | 51 | Get.back(); |
52 | await tester.pumpAndSettle(); | 52 | await tester.pumpAndSettle(); |
53 | 53 | ||
54 | - // expect(find.byType(YourDialogWidget), findsNothing); | 54 | + expect(find.byType(YourDialogWidget), findsNothing); |
55 | // expect(Get.isDialogOpen, false); | 55 | // expect(Get.isDialogOpen, false); |
56 | // await tester.pumpAndSettle(); | 56 | // await tester.pumpAndSettle(); |
57 | }); | 57 | }); |
@@ -47,7 +47,8 @@ void main() { | @@ -47,7 +47,8 @@ void main() { | ||
47 | 47 | ||
48 | await tester.pumpAndSettle(); | 48 | await tester.pumpAndSettle(); |
49 | 49 | ||
50 | - expect(Get.rootController.rootDelegate.currentConfiguration?.route?.name, | 50 | + expect( |
51 | + GetMaterialController.to.rootDelegate.currentConfiguration?.route?.name, | ||
51 | '/404'); | 52 | '/404'); |
52 | }); | 53 | }); |
53 | 54 | ||
@@ -124,7 +125,7 @@ void main() { | @@ -124,7 +125,7 @@ void main() { | ||
124 | ], | 125 | ], |
125 | )); | 126 | )); |
126 | 127 | ||
127 | - await tester.pump(); | 128 | + // await tester.pump(); |
128 | 129 | ||
129 | Get.toNamed('/second'); | 130 | Get.toNamed('/second'); |
130 | await tester.pumpAndSettle(); | 131 | await tester.pumpAndSettle(); |
@@ -134,6 +135,7 @@ void main() { | @@ -134,6 +135,7 @@ void main() { | ||
134 | await tester.pumpAndSettle(); | 135 | await tester.pumpAndSettle(); |
135 | 136 | ||
136 | expect(find.byType(FirstScreen), findsOneWidget); | 137 | expect(find.byType(FirstScreen), findsOneWidget); |
138 | + await tester.pumpAndSettle(); | ||
137 | }); | 139 | }); |
138 | 140 | ||
139 | testWidgets("Get.offAll navigates to provided route", (tester) async { | 141 | testWidgets("Get.offAll navigates to provided route", (tester) async { |
@@ -243,6 +245,8 @@ void main() { | @@ -243,6 +245,8 @@ void main() { | ||
243 | )); | 245 | )); |
244 | 246 | ||
245 | Get.offAndToNamed('/second'); | 247 | Get.offAndToNamed('/second'); |
248 | + | ||
249 | + await tester.pumpAndSettle(); | ||
246 | Get.back(); | 250 | Get.back(); |
247 | 251 | ||
248 | await tester.pumpAndSettle(); | 252 | await tester.pumpAndSettle(); |
@@ -255,6 +259,8 @@ void main() { | @@ -255,6 +259,8 @@ void main() { | ||
255 | 259 | ||
256 | Get.to(() => FirstScreen()); | 260 | Get.to(() => FirstScreen()); |
257 | 261 | ||
262 | + await tester.pumpAndSettle(); | ||
263 | + | ||
258 | Get.offUntil(() => ThirdScreen(), (route) => route.name == '/FirstScreen'); | 264 | Get.offUntil(() => ThirdScreen(), (route) => route.name == '/FirstScreen'); |
259 | 265 | ||
260 | await tester.pumpAndSettle(); | 266 | await tester.pumpAndSettle(); |
@@ -268,9 +274,11 @@ void main() { | @@ -268,9 +274,11 @@ void main() { | ||
268 | await tester.pumpWidget(Wrapper(child: Container())); | 274 | await tester.pumpWidget(Wrapper(child: Container())); |
269 | 275 | ||
270 | Get.to(() => FirstScreen()); | 276 | Get.to(() => FirstScreen()); |
277 | + await tester.pumpAndSettle(); | ||
271 | Get.to(() => SecondScreen()); | 278 | Get.to(() => SecondScreen()); |
272 | - Get.rootController.rootDelegate | ||
273 | - .offUntil(() => ThirdScreen(), (route) => route.name == '/FirstScreen'); | 279 | + await tester.pumpAndSettle(); |
280 | + Get.offUntil(() => ThirdScreen(), (route) => route.name == '/FirstScreen'); | ||
281 | + await tester.pumpAndSettle(); | ||
274 | Get.back(); | 282 | Get.back(); |
275 | 283 | ||
276 | await tester.pumpAndSettle(); | 284 | await tester.pumpAndSettle(); |
@@ -360,11 +368,16 @@ void main() { | @@ -360,11 +368,16 @@ void main() { | ||
360 | testWidgets("Get.back navigates back", (tester) async { | 368 | testWidgets("Get.back navigates back", (tester) async { |
361 | await tester.pumpWidget( | 369 | await tester.pumpWidget( |
362 | Wrapper( | 370 | Wrapper( |
363 | - child: FirstScreen(), | 371 | + child: Container(), |
364 | defaultTransition: Transition.circularReveal, | 372 | defaultTransition: Transition.circularReveal, |
365 | ), | 373 | ), |
366 | ); | 374 | ); |
367 | 375 | ||
376 | + // await tester.pump(); | ||
377 | + | ||
378 | + Get.to(() => FirstScreen()); | ||
379 | + await tester.pumpAndSettle(); | ||
380 | + | ||
368 | Get.to(() => SecondScreen()); | 381 | Get.to(() => SecondScreen()); |
369 | await tester.pumpAndSettle(); | 382 | await tester.pumpAndSettle(); |
370 | Get.back(); | 383 | Get.back(); |
@@ -377,8 +390,17 @@ void main() { | @@ -377,8 +390,17 @@ void main() { | ||
377 | testWidgets( | 390 | testWidgets( |
378 | "Get.back with closeOverlays pops both snackbar and current route", | 391 | "Get.back with closeOverlays pops both snackbar and current route", |
379 | (tester) async { | 392 | (tester) async { |
380 | - await tester.pumpWidget(Wrapper(child: FirstScreen())); | 393 | + await tester.pumpWidget( |
394 | + Wrapper( | ||
395 | + child: Container(), | ||
396 | + defaultTransition: Transition.circularReveal, | ||
397 | + ), | ||
398 | + ); | ||
399 | + | ||
400 | + // await tester.pump(); | ||
381 | 401 | ||
402 | + Get.to(() => FirstScreen()); | ||
403 | + await tester.pumpAndSettle(); | ||
382 | Get.to(() => SecondScreen()); | 404 | Get.to(() => SecondScreen()); |
383 | await tester.pumpAndSettle(); | 405 | await tester.pumpAndSettle(); |
384 | Get.snackbar('title', "message"); | 406 | Get.snackbar('title', "message"); |
@@ -388,6 +410,7 @@ void main() { | @@ -388,6 +410,7 @@ void main() { | ||
388 | await tester.pumpAndSettle(); | 410 | await tester.pumpAndSettle(); |
389 | 411 | ||
390 | expect(Get.isSnackbarOpen, false); | 412 | expect(Get.isSnackbarOpen, false); |
413 | + | ||
391 | expect(find.byType(FirstScreen), findsOneWidget); | 414 | expect(find.byType(FirstScreen), findsOneWidget); |
392 | }); | 415 | }); |
393 | 416 |
1 | -void main() {} | 1 | +import 'package:flutter/cupertino.dart'; |
2 | +import 'package:flutter_test/flutter_test.dart'; | ||
3 | +import 'package:get/get.dart'; | ||
2 | 4 | ||
3 | -// import 'package:flutter/cupertino.dart'; | ||
4 | -// import 'package:flutter_test/flutter_test.dart'; | ||
5 | -// import 'package:get/get.dart'; | 5 | +import 'get_main_test.dart'; |
6 | 6 | ||
7 | -// import 'get_main_test.dart'; | 7 | +class RedirectMiddleware extends GetMiddleware { |
8 | + // @override | ||
9 | + // RouteSettings redirect(String? route) { | ||
10 | + // return RouteSettings(name: '/second'); | ||
11 | + // } | ||
8 | 12 | ||
9 | -// class RedirectMiddleware extends GetMiddleware { | ||
10 | -// @override | ||
11 | -// RouteSettings redirect(String? route) { | ||
12 | -// return RouteSettings(name: '/second'); | ||
13 | -// } | ||
14 | -// } | 13 | + @override |
14 | + Future<RouteDecoder?> redirectDelegate(RouteDecoder route) async { | ||
15 | + return RouteDecoder.fromRoute('/second'); | ||
16 | + } | ||
17 | +} | ||
15 | 18 | ||
16 | -// void main() { | ||
17 | -// testWidgets("Middleware redirect smoke test", (tester) async { | ||
18 | -// await tester.pumpWidget( | ||
19 | -// GetMaterialApp( | ||
20 | -// initialRoute: '/', | ||
21 | -// getPages: [ | ||
22 | -// GetPage(name: '/', page: () => Container()), | ||
23 | -// GetPage(name: '/first', page: () => FirstScreen(), middlewares: [ | ||
24 | -// RedirectMiddleware(), | ||
25 | -// ]), | ||
26 | -// GetPage(name: '/second', page: () => SecondScreen()), | ||
27 | -// GetPage(name: '/third', page: () => ThirdScreen()), | ||
28 | -// ], | ||
29 | -// ), | ||
30 | -// ); | 19 | +void main() { |
20 | + testWidgets("Middleware redirect smoke test", (tester) async { | ||
21 | + await tester.pumpWidget( | ||
22 | + GetMaterialApp( | ||
23 | + initialRoute: '/', | ||
24 | + getPages: [ | ||
25 | + GetPage(name: '/', page: () => Container()), | ||
26 | + GetPage(name: '/first', page: () => FirstScreen(), middlewares: [ | ||
27 | + RedirectMiddleware(), | ||
28 | + ]), | ||
29 | + GetPage(name: '/second', page: () => SecondScreen()), | ||
30 | + GetPage(name: '/third', page: () => ThirdScreen()), | ||
31 | + ], | ||
32 | + ), | ||
33 | + ); | ||
31 | 34 | ||
32 | -// Get.toNamed('/first'); | 35 | + Get.toNamed('/first'); |
33 | 36 | ||
34 | -// await tester.pumpAndSettle(); | ||
35 | -// print(Get.rootController.rootDelegate.currentConfiguration?.route?.name); | ||
36 | -// expect(find.byType(SecondScreen), findsOneWidget); | ||
37 | -// }); | ||
38 | -// } | 37 | + await tester.pumpAndSettle(); |
38 | + print(Get.rootController.rootDelegate.currentConfiguration?.route?.name); | ||
39 | + expect(find.byType(SecondScreen), findsOneWidget); | ||
40 | + }); | ||
41 | +} |
1 | -// import 'package:flutter/cupertino.dart'; | ||
2 | -// import 'package:flutter_test/flutter_test.dart'; | ||
3 | -// import 'package:get/get.dart'; | 1 | +import 'package:flutter/cupertino.dart'; |
2 | +import 'package:flutter_test/flutter_test.dart'; | ||
3 | +import 'package:get/get.dart'; | ||
4 | 4 | ||
5 | -void main() {} | 5 | +void main() { |
6 | + testWidgets('Back swipe dismiss interrupted by route push', (tester) async { | ||
7 | + // final scaffoldKey = GlobalKey(); | ||
6 | 8 | ||
7 | -// void main() { | ||
8 | -// testWidgets('Back swipe dismiss interrupted by route push', (tester) async { | ||
9 | -// // final scaffoldKey = GlobalKey(); | 9 | + await tester.pumpWidget( |
10 | + GetCupertinoApp( | ||
11 | + popGesture: true, | ||
12 | + home: CupertinoPageScaffold( | ||
13 | + // key: scaffoldKey, | ||
14 | + child: Center( | ||
15 | + child: CupertinoButton( | ||
16 | + onPressed: () { | ||
17 | + Get.to( | ||
18 | + () => CupertinoPageScaffold( | ||
19 | + child: Center(child: Text('route')), | ||
20 | + ), | ||
21 | + preventDuplicateHandlingMode: | ||
22 | + PreventDuplicateHandlingMode.Recreate); | ||
23 | + }, | ||
24 | + child: const Text('push'), | ||
25 | + ), | ||
26 | + ), | ||
27 | + ), | ||
28 | + ), | ||
29 | + ); | ||
10 | 30 | ||
11 | -// await tester.pumpWidget( | ||
12 | -// GetCupertinoApp( | ||
13 | -// popGesture: true, | ||
14 | -// home: CupertinoPageScaffold( | ||
15 | -// // key: scaffoldKey, | ||
16 | -// child: Center( | ||
17 | -// child: CupertinoButton( | ||
18 | -// onPressed: () { | ||
19 | -// Get.to( | ||
20 | -// () => CupertinoPageScaffold( | ||
21 | -// child: Center(child: Text('route')), | ||
22 | -// ), | ||
23 | -// preventDuplicateHandlingMode: | ||
24 | -// PreventDuplicateHandlingMode.Recreate); | ||
25 | -// }, | ||
26 | -// child: const Text('push'), | ||
27 | -// ), | ||
28 | -// ), | ||
29 | -// ), | ||
30 | -// ), | ||
31 | -// ); | 31 | + await tester.pumpAndSettle(); |
32 | 32 | ||
33 | -// await tester.pumpAndSettle(); | 33 | + // Check the basic iOS back-swipe dismiss transition. Dragging the pushed |
34 | + // route halfway across the screen will trigger the iOS dismiss animation | ||
34 | 35 | ||
35 | -// // Check the basic iOS back-swipe dismiss transition. Dragging the pushed | ||
36 | -// // route halfway across the screen will trigger the iOS dismiss animation | 36 | + await tester.tap(find.text('push')); |
37 | + await tester.pumpAndSettle(); | ||
38 | + expect(find.text('route'), findsOneWidget); | ||
39 | + expect(find.text('push'), findsNothing); | ||
37 | 40 | ||
38 | -// await tester.tap(find.text('push')); | ||
39 | -// await tester.pumpAndSettle(); | ||
40 | -// expect(find.text('route'), findsOneWidget); | ||
41 | -// expect(find.text('push'), findsNothing); | 41 | + var gesture = await tester.startGesture(const Offset(5, 300)); |
42 | + await gesture.moveBy(const Offset(400, 0)); | ||
43 | + await gesture.up(); | ||
44 | + await tester.pump(); | ||
45 | + expect( | ||
46 | + // The 'route' route has been dragged to the right, halfway across | ||
47 | + // the screen | ||
48 | + tester.getTopLeft(find.ancestor( | ||
49 | + of: find.text('route'), | ||
50 | + matching: find.byType(CupertinoPageScaffold))), | ||
51 | + const Offset(400, 0), | ||
52 | + ); | ||
53 | + expect( | ||
54 | + // The 'push' route is sliding in from the left. | ||
55 | + tester | ||
56 | + .getTopLeft(find.ancestor( | ||
57 | + of: find.text('push'), | ||
58 | + matching: find.byType(CupertinoPageScaffold))) | ||
59 | + .dx, | ||
60 | + moreOrLessEquals(-(400 / 3), epsilon: 1), | ||
61 | + ); | ||
62 | + await tester.pumpAndSettle(); | ||
63 | + expect(find.text('push'), findsOneWidget); | ||
64 | + expect( | ||
65 | + tester.getTopLeft(find.ancestor( | ||
66 | + of: find.text('push'), matching: find.byType(CupertinoPageScaffold))), | ||
67 | + Offset.zero, | ||
68 | + ); | ||
69 | + expect(find.text('route'), findsNothing); | ||
42 | 70 | ||
43 | -// var gesture = await tester.startGesture(const Offset(5, 300)); | ||
44 | -// await gesture.moveBy(const Offset(400, 0)); | ||
45 | -// await gesture.up(); | ||
46 | -// await tester.pump(); | ||
47 | -// expect( | ||
48 | -// // The 'route' route has been dragged to the right, halfway across | ||
49 | -// // the screen | ||
50 | -// tester.getTopLeft(find.ancestor( | ||
51 | -// of: find.text('route'), | ||
52 | -// matching: find.byType(CupertinoPageScaffold))), | ||
53 | -// const Offset(400, 0), | ||
54 | -// ); | ||
55 | -// expect( | ||
56 | -// // The 'push' route is sliding in from the left. | ||
57 | -// tester | ||
58 | -// .getTopLeft(find.ancestor( | ||
59 | -// of: find.text('push'), | ||
60 | -// matching: find.byType(CupertinoPageScaffold))) | ||
61 | -// .dx, | ||
62 | -// 400 / 3, | ||
63 | -// ); | ||
64 | -// await tester.pumpAndSettle(); | ||
65 | -// expect(find.text('push'), findsOneWidget); | ||
66 | -// expect( | ||
67 | -// tester.getTopLeft(find.ancestor( | ||
68 | -// of: find.text('push'), matching: find.byType(CupertinoPageScaffold))), | ||
69 | -// Offset.zero, | ||
70 | -// ); | ||
71 | -// expect(find.text('route'), findsNothing); | 71 | + // Run the dismiss animation 60%, which exposes the route "push" button, |
72 | + // and then press the button. | ||
72 | 73 | ||
73 | -// // Run the dismiss animation 60%, which exposes the route "push" button, | ||
74 | -// // and then press the button. | 74 | + await tester.tap(find.text('push')); |
75 | + await tester.pumpAndSettle(); | ||
76 | + expect(find.text('route'), findsOneWidget); | ||
77 | + expect(find.text('push'), findsNothing); | ||
75 | 78 | ||
76 | -// await tester.tap(find.text('push')); | ||
77 | -// await tester.pumpAndSettle(); | ||
78 | -// expect(find.text('route'), findsOneWidget); | ||
79 | -// expect(find.text('push'), findsNothing); | ||
80 | - | ||
81 | -// gesture = await tester.startGesture(const Offset(5, 300)); | ||
82 | -// await gesture.moveBy(const Offset(400, 0)); // Drag halfway. | ||
83 | -// await gesture.up(); | ||
84 | -// // Trigger the snapping animation. | ||
85 | -// // Since the back swipe drag was brought to >=50% of the screen, it will | ||
86 | -// // self snap to finish the pop transition as the gesture is lifted. | ||
87 | -// // | ||
88 | -// // This drag drop animation is 400ms when dropped exactly halfway | ||
89 | -// // (800 / [pixel distance remaining], see | ||
90 | -// // _CupertinoBackGestureController.dragEnd). It follows a curve that is very | ||
91 | -// // steep initially. | ||
92 | -// await tester.pump(); | ||
93 | -// expect( | ||
94 | -// tester.getTopLeft(find.ancestor( | ||
95 | -// of: find.text('route'), | ||
96 | -// matching: find.byType(CupertinoPageScaffold))), | ||
97 | -// const Offset(400, 0), | ||
98 | -// ); | ||
99 | -// // Let the dismissing snapping animation go 60%. | ||
100 | -// await tester.pump(const Duration(milliseconds: 240)); | ||
101 | -// expect( | ||
102 | -// tester | ||
103 | -// .getTopLeft(find.ancestor( | ||
104 | -// of: find.text('route'), | ||
105 | -// matching: find.byType(CupertinoPageScaffold))) | ||
106 | -// .dx, | ||
107 | -// moreOrLessEquals(798, epsilon: 1), | ||
108 | -// ); | ||
109 | - | ||
110 | -// // Use the navigator to push a route instead of tapping the 'push' button. | ||
111 | -// // The topmost route (the one that's animating away), ignores input while | ||
112 | -// // the pop is underway because route.navigator.userGestureInProgress. | ||
113 | -// Get.to(() => const CupertinoPageScaffold( | ||
114 | -// child: Center(child: Text('route')), | ||
115 | -// )); | ||
116 | - | ||
117 | -// await tester.pumpAndSettle(); | ||
118 | -// expect(find.text('route'), findsOneWidget); | ||
119 | -// expect(find.text('push'), findsNothing); | ||
120 | -// expect( | ||
121 | -// tester | ||
122 | -// .state<NavigatorState>(find.byType(Navigator)) | ||
123 | -// .userGestureInProgress, | ||
124 | -// false, | ||
125 | -// ); | ||
126 | -// }); | ||
127 | -// } | 79 | + gesture = await tester.startGesture(const Offset(5, 300)); |
80 | + await gesture.moveBy(const Offset(400, 0)); // Drag halfway. | ||
81 | + await gesture.up(); | ||
82 | + // Trigger the snapping animation. | ||
83 | + // Since the back swipe drag was brought to >=50% of the screen, it will | ||
84 | + // self snap to finish the pop transition as the gesture is lifted. | ||
85 | + // | ||
86 | + // This drag drop animation is 400ms when dropped exactly halfway | ||
87 | + // (800 / [pixel distance remaining], see | ||
88 | + // _CupertinoBackGestureController.dragEnd). It follows a curve that is very | ||
89 | + // steep initially. | ||
90 | + await tester.pump(); | ||
91 | + expect( | ||
92 | + tester.getTopLeft(find.ancestor( | ||
93 | + of: find.text('route'), | ||
94 | + matching: find.byType(CupertinoPageScaffold))), | ||
95 | + const Offset(400, 0), | ||
96 | + ); | ||
97 | + // Let the dismissing snapping animation go 60%. | ||
98 | + await tester.pump(const Duration(milliseconds: 240)); | ||
99 | + expect( | ||
100 | + tester | ||
101 | + .getTopLeft(find.ancestor( | ||
102 | + of: find.text('route'), | ||
103 | + matching: find.byType(CupertinoPageScaffold))) | ||
104 | + .dx, | ||
105 | + moreOrLessEquals(798, epsilon: 1), | ||
106 | + ); | ||
107 | + }); | ||
108 | +} |
@@ -104,6 +104,7 @@ void main() { | @@ -104,6 +104,7 @@ void main() { | ||
104 | expect(find.text('title'), findsNothing); | 104 | expect(find.text('title'), findsNothing); |
105 | expect(find.text('titleTwo'), findsOneWidget); | 105 | expect(find.text('titleTwo'), findsOneWidget); |
106 | Get.closeAllSnackbars(); | 106 | Get.closeAllSnackbars(); |
107 | + await tester.pumpAndSettle(); | ||
107 | }); | 108 | }); |
108 | 109 | ||
109 | testWidgets("test snackbar dismissible", (tester) async { | 110 | testWidgets("test snackbar dismissible", (tester) async { |
@@ -23,9 +23,11 @@ class Wrapper extends StatelessWidget { | @@ -23,9 +23,11 @@ class Wrapper extends StatelessWidget { | ||
23 | translations: WrapperTranslations(), | 23 | translations: WrapperTranslations(), |
24 | locale: WrapperTranslations.locale, | 24 | locale: WrapperTranslations.locale, |
25 | getPages: namedRoutes, | 25 | getPages: namedRoutes, |
26 | - home: Scaffold( | 26 | + home: namedRoutes == null |
27 | + ? Scaffold( | ||
27 | body: child, | 28 | body: child, |
28 | - ), | 29 | + ) |
30 | + : null, | ||
29 | ); | 31 | ); |
30 | } | 32 | } |
31 | } | 33 | } |
@@ -97,7 +97,7 @@ void main() { | @@ -97,7 +97,7 @@ void main() { | ||
97 | controller.close(); | 97 | controller.close(); |
98 | }); | 98 | }); |
99 | 99 | ||
100 | - test('Rx same value will not call the same listener when `call`', () async { | 100 | + test('Rx same value will not call the same listener when call', () async { |
101 | var reactiveInteger = RxInt(2); | 101 | var reactiveInteger = RxInt(2); |
102 | var timesCalled = 0; | 102 | var timesCalled = 0; |
103 | reactiveInteger.listen((newInt) { | 103 | reactiveInteger.listen((newInt) { |
@@ -114,7 +114,7 @@ void main() { | @@ -114,7 +114,7 @@ void main() { | ||
114 | expect(1, timesCalled); | 114 | expect(1, timesCalled); |
115 | }); | 115 | }); |
116 | 116 | ||
117 | - test('Rx different value will call the listener when `trigger`', () async { | 117 | + test('Rx different value will call the listener when trigger', () async { |
118 | var reactiveInteger = RxInt(0); | 118 | var reactiveInteger = RxInt(0); |
119 | var timesCalled = 0; | 119 | var timesCalled = 0; |
120 | reactiveInteger.listen((newInt) { | 120 | reactiveInteger.listen((newInt) { |
@@ -131,7 +131,7 @@ void main() { | @@ -131,7 +131,7 @@ void main() { | ||
131 | expect(3, timesCalled); | 131 | expect(3, timesCalled); |
132 | }); | 132 | }); |
133 | 133 | ||
134 | - test('Rx same value will call the listener when `trigger`', () async { | 134 | + test('Rx same value will call the listener when trigger', () async { |
135 | var reactiveInteger = RxInt(2); | 135 | var reactiveInteger = RxInt(2); |
136 | var timesCalled = 0; | 136 | var timesCalled = 0; |
137 | reactiveInteger.listen((newInt) { | 137 | reactiveInteger.listen((newInt) { |
-
Please register or login to post a comment