Committed by
GitHub
Merge pull request #2607 from jonataslaw/improve-speed
Improve speed
Showing
12 changed files
with
105 additions
and
145 deletions
@@ -6,14 +6,12 @@ import 'dart:convert'; | @@ -6,14 +6,12 @@ import 'dart:convert'; | ||
6 | 6 | ||
7 | class CasesModel { | 7 | class CasesModel { |
8 | CasesModel({ | 8 | CasesModel({ |
9 | - required this.id, | ||
10 | required this.message, | 9 | required this.message, |
11 | required this.global, | 10 | required this.global, |
12 | required this.countries, | 11 | required this.countries, |
13 | required this.date, | 12 | required this.date, |
14 | }); | 13 | }); |
15 | 14 | ||
16 | - final String id; | ||
17 | final String message; | 15 | final String message; |
18 | final Global global; | 16 | final Global global; |
19 | final List<Country> countries; | 17 | final List<Country> countries; |
@@ -25,7 +23,6 @@ class CasesModel { | @@ -25,7 +23,6 @@ class CasesModel { | ||
25 | String toRawJson() => json.encode(toJson()); | 23 | String toRawJson() => json.encode(toJson()); |
26 | 24 | ||
27 | factory CasesModel.fromJson(Map<String, dynamic> json) => CasesModel( | 25 | factory CasesModel.fromJson(Map<String, dynamic> json) => CasesModel( |
28 | - id: json["ID"] as String, | ||
29 | message: json["Message"] as String, | 26 | message: json["Message"] as String, |
30 | global: Global.fromJson(json["Global"] as Map<String, dynamic>), | 27 | global: Global.fromJson(json["Global"] as Map<String, dynamic>), |
31 | countries: List<Country>.from((json["Countries"] as Iterable).map( | 28 | countries: List<Country>.from((json["Countries"] as Iterable).map( |
@@ -35,7 +32,6 @@ class CasesModel { | @@ -35,7 +32,6 @@ class CasesModel { | ||
35 | ); | 32 | ); |
36 | 33 | ||
37 | Map<String, dynamic> toJson() => { | 34 | Map<String, dynamic> toJson() => { |
38 | - "ID": id, | ||
39 | "Message": message, | 35 | "Message": message, |
40 | "Global": global.toJson(), | 36 | "Global": global.toJson(), |
41 | "Countries": List<dynamic>.from(countries.map((x) => x.toJson())), | 37 | "Countries": List<dynamic>.from(countries.map((x) => x.toJson())), |
@@ -25,7 +25,6 @@ class MockRepositorySuccess implements IHomeRepository { | @@ -25,7 +25,6 @@ class MockRepositorySuccess implements IHomeRepository { | ||
25 | totalRecovered: 0), | 25 | totalRecovered: 0), |
26 | countries: [], | 26 | countries: [], |
27 | date: DateTime.now(), | 27 | date: DateTime.now(), |
28 | - id: '', | ||
29 | message: '', | 28 | message: '', |
30 | ); | 29 | ); |
31 | } | 30 | } |
@@ -21,6 +21,6 @@ | @@ -21,6 +21,6 @@ | ||
21 | <key>CFBundleVersion</key> | 21 | <key>CFBundleVersion</key> |
22 | <string>1.0</string> | 22 | <string>1.0</string> |
23 | <key>MinimumOSVersion</key> | 23 | <key>MinimumOSVersion</key> |
24 | - <string>9.0</string> | 24 | + <string>11.0</string> |
25 | </dict> | 25 | </dict> |
26 | </plist> | 26 | </plist> |
@@ -7,6 +7,7 @@ FLUTTER_BUILD_DIR=build | @@ -7,6 +7,7 @@ FLUTTER_BUILD_DIR=build | ||
7 | FLUTTER_BUILD_NAME=1.0.0 | 7 | FLUTTER_BUILD_NAME=1.0.0 |
8 | FLUTTER_BUILD_NUMBER=1 | 8 | FLUTTER_BUILD_NUMBER=1 |
9 | EXCLUDED_ARCHS[sdk=iphonesimulator*]=i386 | 9 | EXCLUDED_ARCHS[sdk=iphonesimulator*]=i386 |
10 | +EXCLUDED_ARCHS[sdk=iphoneos*]=armv7 | ||
10 | DART_DEFINES=RkxVVFRFUl9XRUJfQVVUT19ERVRFQ1Q9dHJ1ZQ== | 11 | DART_DEFINES=RkxVVFRFUl9XRUJfQVVUT19ERVRFQ1Q9dHJ1ZQ== |
11 | DART_OBFUSCATION=false | 12 | DART_OBFUSCATION=false |
12 | TRACK_WIDGET_CREATION=true | 13 | TRACK_WIDGET_CREATION=true |
@@ -272,7 +272,7 @@ | @@ -272,7 +272,7 @@ | ||
272 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; | 272 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; |
273 | GCC_WARN_UNUSED_FUNCTION = YES; | 273 | GCC_WARN_UNUSED_FUNCTION = YES; |
274 | GCC_WARN_UNUSED_VARIABLE = YES; | 274 | GCC_WARN_UNUSED_VARIABLE = YES; |
275 | - IPHONEOS_DEPLOYMENT_TARGET = 9.0; | 275 | + IPHONEOS_DEPLOYMENT_TARGET = 11.0; |
276 | MTL_ENABLE_DEBUG_INFO = NO; | 276 | MTL_ENABLE_DEBUG_INFO = NO; |
277 | SDKROOT = iphoneos; | 277 | SDKROOT = iphoneos; |
278 | SUPPORTED_PLATFORMS = iphoneos; | 278 | SUPPORTED_PLATFORMS = iphoneos; |
@@ -346,7 +346,7 @@ | @@ -346,7 +346,7 @@ | ||
346 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; | 346 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; |
347 | GCC_WARN_UNUSED_FUNCTION = YES; | 347 | GCC_WARN_UNUSED_FUNCTION = YES; |
348 | GCC_WARN_UNUSED_VARIABLE = YES; | 348 | GCC_WARN_UNUSED_VARIABLE = YES; |
349 | - IPHONEOS_DEPLOYMENT_TARGET = 9.0; | 349 | + IPHONEOS_DEPLOYMENT_TARGET = 11.0; |
350 | MTL_ENABLE_DEBUG_INFO = YES; | 350 | MTL_ENABLE_DEBUG_INFO = YES; |
351 | ONLY_ACTIVE_ARCH = YES; | 351 | ONLY_ACTIVE_ARCH = YES; |
352 | SDKROOT = iphoneos; | 352 | SDKROOT = iphoneos; |
@@ -395,7 +395,7 @@ | @@ -395,7 +395,7 @@ | ||
395 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; | 395 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; |
396 | GCC_WARN_UNUSED_FUNCTION = YES; | 396 | GCC_WARN_UNUSED_FUNCTION = YES; |
397 | GCC_WARN_UNUSED_VARIABLE = YES; | 397 | GCC_WARN_UNUSED_VARIABLE = YES; |
398 | - IPHONEOS_DEPLOYMENT_TARGET = 9.0; | 398 | + IPHONEOS_DEPLOYMENT_TARGET = 11.0; |
399 | MTL_ENABLE_DEBUG_INFO = NO; | 399 | MTL_ENABLE_DEBUG_INFO = NO; |
400 | SDKROOT = iphoneos; | 400 | SDKROOT = iphoneos; |
401 | SUPPORTED_PLATFORMS = iphoneos; | 401 | SUPPORTED_PLATFORMS = iphoneos; |
@@ -76,8 +76,7 @@ class Request<T> { | @@ -76,8 +76,7 @@ class Request<T> { | ||
76 | files: files, | 76 | files: files, |
77 | persistentConnection: persistentConnection, | 77 | persistentConnection: persistentConnection, |
78 | decoder: decoder, | 78 | decoder: decoder, |
79 | - responseInterceptor: responseInterceptor | ||
80 | - ); | 79 | + responseInterceptor: responseInterceptor); |
81 | } | 80 | } |
82 | 81 | ||
83 | Request<T> copyWith({ | 82 | Request<T> copyWith({ |
@@ -110,14 +109,12 @@ class Request<T> { | @@ -110,14 +109,12 @@ class Request<T> { | ||
110 | files: files ?? this.files, | 109 | files: files ?? this.files, |
111 | persistentConnection: persistentConnection ?? this.persistentConnection, | 110 | persistentConnection: persistentConnection ?? this.persistentConnection, |
112 | decoder: decoder ?? this.decoder, | 111 | decoder: decoder ?? this.decoder, |
113 | - responseInterceptor: responseInterceptor ?? this.responseInterceptor | ||
114 | - ); | 112 | + responseInterceptor: responseInterceptor ?? this.responseInterceptor); |
115 | } | 113 | } |
116 | } | 114 | } |
117 | 115 | ||
118 | extension BodyBytesStream on Stream<List<int>> { | 116 | extension BodyBytesStream on Stream<List<int>> { |
119 | - static Stream<List<int>> fromBytes(List<int> bytes) => | ||
120 | - Stream.fromIterable([bytes]); | 117 | + static Stream<List<int>> fromBytes(List<int> bytes) => Stream.value(bytes); |
121 | 118 | ||
122 | Future<Uint8List> toBytes() { | 119 | Future<Uint8List> toBytes() { |
123 | var completer = Completer<Uint8List>(); | 120 | var completer = Completer<Uint8List>(); |
@@ -170,9 +170,13 @@ extension Inst on GetInterface { | @@ -170,9 +170,13 @@ extension Inst on GetInterface { | ||
170 | final isInit = _singl[key]!.isInit; | 170 | final isInit = _singl[key]!.isInit; |
171 | S? i; | 171 | S? i; |
172 | if (!isInit) { | 172 | if (!isInit) { |
173 | - i = _startController<S>(tag: name); | ||
174 | - if (_singl[key]!.isSingleton!) { | 173 | + final isSingleton = _singl[key]?.isSingleton ?? false; |
174 | + if (isSingleton) { | ||
175 | _singl[key]!.isInit = true; | 175 | _singl[key]!.isInit = true; |
176 | + } | ||
177 | + i = _startController<S>(tag: name); | ||
178 | + | ||
179 | + if (isSingleton) { | ||
176 | if (Get.smartManagement != SmartManagement.onlyBuilder) { | 180 | if (Get.smartManagement != SmartManagement.onlyBuilder) { |
177 | RouterReportManager.instance | 181 | RouterReportManager.instance |
178 | .reportDependencyLinkedToRoute(_getKey(S, name)); | 182 | .reportDependencyLinkedToRoute(_getKey(S, name)); |
@@ -17,9 +17,7 @@ mixin GetLifeCycleMixin { | @@ -17,9 +17,7 @@ mixin GetLifeCycleMixin { | ||
17 | @protected | 17 | @protected |
18 | @mustCallSuper | 18 | @mustCallSuper |
19 | void onInit() { | 19 | void onInit() { |
20 | - | ||
21 | - ambiguate(Engine.instance) | ||
22 | - ?.addPostFrameCallback((_) => onReady()); | 20 | + ambiguate(Engine.instance)?.addPostFrameCallback((_) => onReady()); |
23 | } | 21 | } |
24 | 22 | ||
25 | /// Called 1 frame after onInit(). It is the perfect place to enter | 23 | /// Called 1 frame after onInit(). It is the perfect place to enter |
@@ -2,10 +2,7 @@ import 'dart:ui' as ui; | @@ -2,10 +2,7 @@ import 'dart:ui' as ui; | ||
2 | 2 | ||
3 | import 'package:flutter/material.dart'; | 3 | import 'package:flutter/material.dart'; |
4 | 4 | ||
5 | -import '../../get_core/get_core.dart'; | ||
6 | -import '../../get_instance/src/bindings_interface.dart'; | ||
7 | -import '../../get_utils/get_utils.dart'; | ||
8 | -import '../get_navigation.dart'; | 5 | +import '../../get.dart'; |
9 | import 'dialog/dialog_route.dart'; | 6 | import 'dialog/dialog_route.dart'; |
10 | 7 | ||
11 | /// It replaces the Flutter Navigator, but needs no context. | 8 | /// It replaces the Flutter Navigator, but needs no context. |
@@ -1259,8 +1256,8 @@ extension GetNavigationExt on GetInterface { | @@ -1259,8 +1256,8 @@ extension GetNavigationExt on GetInterface { | ||
1259 | TDelegate? delegate<TDelegate extends RouterDelegate<TPage>, TPage>() => | 1256 | TDelegate? delegate<TDelegate extends RouterDelegate<TPage>, TPage>() => |
1260 | _getxController.routerDelegate as TDelegate?; | 1257 | _getxController.routerDelegate as TDelegate?; |
1261 | 1258 | ||
1262 | - | ||
1263 | - GetMaterialController get _getxController => GetMaterialController.to; | 1259 | + static final GetMaterialController _getxController = |
1260 | + Get.find<GetMaterialController>(); | ||
1264 | } | 1261 | } |
1265 | 1262 | ||
1266 | extension OverlayExt on GetInterface { | 1263 | extension OverlayExt on GetInterface { |
@@ -7,6 +7,7 @@ import '../../../get_instance/get_instance.dart'; | @@ -7,6 +7,7 @@ import '../../../get_instance/get_instance.dart'; | ||
7 | import '../../../get_state_manager/get_state_manager.dart'; | 7 | import '../../../get_state_manager/get_state_manager.dart'; |
8 | import '../../../get_utils/get_utils.dart'; | 8 | import '../../../get_utils/get_utils.dart'; |
9 | import '../../get_navigation.dart'; | 9 | import '../../get_navigation.dart'; |
10 | +import '../router_report.dart'; | ||
10 | 11 | ||
11 | class GetCupertinoApp extends StatelessWidget { | 12 | class GetCupertinoApp extends StatelessWidget { |
12 | final GlobalKey<NavigatorState>? navigatorKey; | 13 | final GlobalKey<NavigatorState>? navigatorKey; |
@@ -62,6 +63,9 @@ class GetCupertinoApp extends StatelessWidget { | @@ -62,6 +63,9 @@ class GetCupertinoApp extends StatelessWidget { | ||
62 | final BackButtonDispatcher? backButtonDispatcher; | 63 | final BackButtonDispatcher? backButtonDispatcher; |
63 | final CupertinoThemeData? theme; | 64 | final CupertinoThemeData? theme; |
64 | final bool useInheritedMediaQuery; | 65 | final bool useInheritedMediaQuery; |
66 | + final List<Bind> binds; | ||
67 | + final ScrollBehavior? scrollBehavior; | ||
68 | + | ||
65 | GetCupertinoApp({ | 69 | GetCupertinoApp({ |
66 | Key? key, | 70 | Key? key, |
67 | this.theme, | 71 | this.theme, |
@@ -86,6 +90,8 @@ class GetCupertinoApp extends StatelessWidget { | @@ -86,6 +90,8 @@ class GetCupertinoApp extends StatelessWidget { | ||
86 | this.onInit, | 90 | this.onInit, |
87 | this.onDispose, | 91 | this.onDispose, |
88 | this.locale, | 92 | this.locale, |
93 | + this.binds = const [], | ||
94 | + this.scrollBehavior, | ||
89 | this.fallbackLocale, | 95 | this.fallbackLocale, |
90 | this.localizationsDelegates, | 96 | this.localizationsDelegates, |
91 | this.localeListResolutionCallback, | 97 | this.localeListResolutionCallback, |
@@ -156,6 +162,8 @@ class GetCupertinoApp extends StatelessWidget { | @@ -156,6 +162,8 @@ class GetCupertinoApp extends StatelessWidget { | ||
156 | this.showSemanticsDebugger = false, | 162 | this.showSemanticsDebugger = false, |
157 | this.debugShowCheckedModeBanner = true, | 163 | this.debugShowCheckedModeBanner = true, |
158 | this.shortcuts, | 164 | this.shortcuts, |
165 | + this.binds = const [], | ||
166 | + this.scrollBehavior, | ||
159 | this.actions, | 167 | this.actions, |
160 | this.customTransition, | 168 | this.customTransition, |
161 | this.translationsKeys, | 169 | this.translationsKeys, |
@@ -188,87 +196,72 @@ class GetCupertinoApp extends StatelessWidget { | @@ -188,87 +196,72 @@ class GetCupertinoApp extends StatelessWidget { | ||
188 | super(key: key); | 196 | super(key: key); |
189 | 197 | ||
190 | @override | 198 | @override |
191 | - Widget build(BuildContext context) => GetBuilder<GetMaterialController>( | ||
192 | - init: Get.rootController, | ||
193 | - dispose: (d) { | ||
194 | - onDispose?.call(); | ||
195 | - // Get.clearRouteTree(); | ||
196 | - // Get.clearTranslations(); | ||
197 | - // Get.resetRootNavigator(); | ||
198 | - // Get.routerDelegate = null; | ||
199 | - // Get.routeInformationParser = null; | ||
200 | - }, | ||
201 | - initState: (i) { | ||
202 | - Get.engine.addPostFrameCallback((timeStamp) { | ||
203 | - onReady?.call(); | ||
204 | - }); | ||
205 | - if (locale != null) Get.locale = locale; | ||
206 | - | ||
207 | - if (fallbackLocale != null) Get.fallbackLocale = fallbackLocale; | ||
208 | - | ||
209 | - if (translations != null) { | ||
210 | - Get.addTranslations(translations!.keys); | ||
211 | - } else if (translationsKeys != null) { | ||
212 | - Get.addTranslations(translationsKeys!); | ||
213 | - } | ||
214 | - | ||
215 | - // Get.customTransition = customTransition; | ||
216 | - | ||
217 | - initialBinding?.dependencies(); | ||
218 | - // if (getPages != null) { | ||
219 | - // Get.addPages(getPages!); | ||
220 | - // } else { | ||
221 | - // Get.addPage( | ||
222 | - // GetPage( | ||
223 | - // name: _cleanRouteName("/${home.runtimeType}"), | ||
224 | - // page: () => home!, | ||
225 | - // ), | ||
226 | - // ); | ||
227 | - // } | ||
228 | - | ||
229 | - Get.smartManagement = smartManagement; | ||
230 | - onInit?.call(); | ||
231 | - | ||
232 | - Get.config( | ||
233 | - enableLog: enableLog ?? Get.isLogEnable, | 199 | + Widget build(BuildContext context) { |
200 | + return Binds( | ||
201 | + binds: [ | ||
202 | + Bind.lazyPut<GetMaterialController>( | ||
203 | + () => GetMaterialController( | ||
204 | + ConfigData( | ||
205 | + backButtonDispatcher: backButtonDispatcher, | ||
206 | + binds: binds, | ||
207 | + customTransition: customTransition, | ||
208 | + defaultGlobalState: defaultGlobalState, | ||
209 | + defaultTransition: defaultTransition, | ||
210 | + enableLog: enableLog, | ||
211 | + fallbackLocale: fallbackLocale, | ||
212 | + getPages: getPages, | ||
213 | + home: home, | ||
214 | + initialRoute: initialRoute, | ||
215 | + locale: locale, | ||
234 | logWriterCallback: logWriterCallback, | 216 | logWriterCallback: logWriterCallback, |
235 | - defaultTransition: defaultTransition ?? Get.defaultTransition, | ||
236 | - defaultOpaqueRoute: opaqueRoute ?? Get.isOpaqueRouteDefault, | ||
237 | - defaultPopGesture: popGesture ?? Get.isPopGestureEnable, | ||
238 | - defaultDurationTransition: | ||
239 | - transitionDuration ?? Get.defaultTransitionDuration, | ||
240 | - ); | ||
241 | - }, | ||
242 | - builder: (_) { | ||
243 | - final routerDelegate = _.createDelegate( | ||
244 | - pages: getPages ?? [], | ||
245 | - notFoundRoute: unknownRoute, | ||
246 | navigatorKey: navigatorKey, | 217 | navigatorKey: navigatorKey, |
247 | - navigatorObservers: (navigatorObservers == null | ||
248 | - ? <NavigatorObserver>[ | ||
249 | - GetObserver(routingCallback, Get.routing) | ||
250 | - ] | ||
251 | - : <NavigatorObserver>[ | ||
252 | - GetObserver(routingCallback, Get.routing) | ||
253 | - ] | ||
254 | - ..addAll(navigatorObservers!))); | ||
255 | - final routeInformationParser = _.createInformationParser( | ||
256 | - initialRoute: initialRoute ?? | ||
257 | - getPages?.first.name ?? | ||
258 | - _cleanRouteName("/${home.runtimeType}"), | ||
259 | - ); | ||
260 | - | ||
261 | - return CupertinoApp.router( | ||
262 | - routerDelegate: routerDelegate, | 218 | + navigatorObservers: navigatorObservers, |
219 | + onDispose: onDispose, | ||
220 | + onInit: onInit, | ||
221 | + onReady: onReady, | ||
222 | + opaqueRoute: opaqueRoute, | ||
223 | + popGesture: popGesture, | ||
263 | routeInformationParser: routeInformationParser, | 224 | routeInformationParser: routeInformationParser, |
225 | + routeInformationProvider: routeInformationProvider, | ||
226 | + routerDelegate: routerDelegate, | ||
227 | + routingCallback: routingCallback, | ||
228 | + scaffoldMessengerKey: GlobalKey<ScaffoldMessengerState>(), | ||
229 | + smartManagement: smartManagement, | ||
230 | + transitionDuration: transitionDuration, | ||
231 | + translations: translations, | ||
232 | + translationsKeys: translationsKeys, | ||
233 | + unknownRoute: unknownRoute, | ||
234 | + ), | ||
235 | + ), | ||
236 | + onClose: () { | ||
237 | + Get.clearTranslations(); | ||
238 | + RouterReportManager.dispose(); | ||
239 | + Get.resetInstance(clearRouteBindings: true); | ||
240 | + }, | ||
241 | + ), | ||
242 | + ...binds, | ||
243 | + ], | ||
244 | + child: Builder(builder: (context) { | ||
245 | + final controller = context.listen<GetMaterialController>(); | ||
246 | + return CupertinoApp.router( | ||
247 | + routerDelegate: controller.routerDelegate, | ||
248 | + routeInformationParser: controller.routeInformationParser, | ||
264 | backButtonDispatcher: backButtonDispatcher, | 249 | backButtonDispatcher: backButtonDispatcher, |
265 | routeInformationProvider: routeInformationProvider, | 250 | routeInformationProvider: routeInformationProvider, |
266 | - key: _.unikey, | ||
267 | - theme: theme, | ||
268 | - builder: defaultBuilder, | 251 | + key: controller.unikey, |
252 | + builder: (context, child) => Directionality( | ||
253 | + textDirection: textDirection ?? | ||
254 | + (rtlLanguages.contains(Get.locale?.languageCode) | ||
255 | + ? TextDirection.rtl | ||
256 | + : TextDirection.ltr), | ||
257 | + child: builder == null | ||
258 | + ? (child ?? Material()) | ||
259 | + : builder!(context, child ?? Material()), | ||
260 | + ), | ||
269 | title: title, | 261 | title: title, |
270 | onGenerateTitle: onGenerateTitle, | 262 | onGenerateTitle: onGenerateTitle, |
271 | color: color, | 263 | color: color, |
264 | + theme: theme, | ||
272 | locale: Get.locale ?? locale, | 265 | locale: Get.locale ?? locale, |
273 | localizationsDelegates: localizationsDelegates, | 266 | localizationsDelegates: localizationsDelegates, |
274 | localeListResolutionCallback: localeListResolutionCallback, | 267 | localeListResolutionCallback: localeListResolutionCallback, |
@@ -280,33 +273,10 @@ class GetCupertinoApp extends StatelessWidget { | @@ -280,33 +273,10 @@ class GetCupertinoApp extends StatelessWidget { | ||
280 | showSemanticsDebugger: showSemanticsDebugger, | 273 | showSemanticsDebugger: showSemanticsDebugger, |
281 | debugShowCheckedModeBanner: debugShowCheckedModeBanner, | 274 | debugShowCheckedModeBanner: debugShowCheckedModeBanner, |
282 | shortcuts: shortcuts, | 275 | shortcuts: shortcuts, |
276 | + scrollBehavior: scrollBehavior, | ||
283 | useInheritedMediaQuery: useInheritedMediaQuery, | 277 | useInheritedMediaQuery: useInheritedMediaQuery, |
284 | ); | 278 | ); |
285 | - }, | ||
286 | - ); | ||
287 | - | ||
288 | - Widget defaultBuilder(BuildContext context, Widget? child) { | ||
289 | - return Directionality( | ||
290 | - textDirection: textDirection ?? | ||
291 | - (rtlLanguages.contains(Get.locale?.languageCode) | ||
292 | - ? TextDirection.rtl | ||
293 | - : TextDirection.ltr), | ||
294 | - child: builder == null | ||
295 | - ? (child ?? Material()) | ||
296 | - : builder!(context, child ?? Material()), | 279 | + }), |
297 | ); | 280 | ); |
298 | } | 281 | } |
299 | - | ||
300 | - // Route<dynamic> generator(RouteSettings settings) { | ||
301 | - // return PageRedirect(settings: settings, unknownRoute: unknownRoute).page(); | ||
302 | - // } | ||
303 | - | ||
304 | - // List<Route<dynamic>> initialRoutesGenerate(String name) { | ||
305 | - // return [ | ||
306 | - // PageRedirect( | ||
307 | - // settings: RouteSettings(name: name), | ||
308 | - // unknownRoute: unknownRoute, | ||
309 | - // ).page() | ||
310 | - // ]; | ||
311 | - // } | ||
312 | } | 282 | } |
@@ -70,10 +70,6 @@ class ConfigData { | @@ -70,10 +70,6 @@ class ConfigData { | ||
70 | class GetMaterialController extends FullLifeCycleController { | 70 | class GetMaterialController extends FullLifeCycleController { |
71 | GetMaterialController(this.config); | 71 | GetMaterialController(this.config); |
72 | 72 | ||
73 | - static GetMaterialController get to { | ||
74 | - return Get.find(); | ||
75 | - } | ||
76 | - | ||
77 | late final RouterDelegate<Object> routerDelegate; | 73 | late final RouterDelegate<Object> routerDelegate; |
78 | late final RouteInformationParser<Object> routeInformationParser; | 74 | late final RouteInformationParser<Object> routeInformationParser; |
79 | final ConfigData config; | 75 | final ConfigData config; |
@@ -91,7 +87,7 @@ class GetMaterialController extends FullLifeCycleController { | @@ -91,7 +87,7 @@ class GetMaterialController extends FullLifeCycleController { | ||
91 | if (config.getPages == null && config.home == null) { | 87 | if (config.getPages == null && config.home == null) { |
92 | throw 'You need add pages or home'; | 88 | throw 'You need add pages or home'; |
93 | } | 89 | } |
94 | - | 90 | + print('route delefate from onInit'); |
95 | routerDelegate = config.routerDelegate ?? | 91 | routerDelegate = config.routerDelegate ?? |
96 | createDelegate( | 92 | createDelegate( |
97 | pages: config.getPages ?? | 93 | pages: config.getPages ?? |
@@ -104,13 +100,20 @@ class GetMaterialController extends FullLifeCycleController { | @@ -104,13 +100,20 @@ class GetMaterialController extends FullLifeCycleController { | ||
104 | notFoundRoute: config.unknownRoute, | 100 | notFoundRoute: config.unknownRoute, |
105 | navigatorKey: config.navigatorKey, | 101 | navigatorKey: config.navigatorKey, |
106 | navigatorObservers: (config.navigatorObservers == null | 102 | navigatorObservers: (config.navigatorObservers == null |
107 | - ? <NavigatorObserver>[GetObserver(config.routingCallback, Get.routing)] | ||
108 | - : <NavigatorObserver>[GetObserver(config.routingCallback, routing), ...config.navigatorObservers!]), | 103 | + ? <NavigatorObserver>[ |
104 | + GetObserver(config.routingCallback, Get.routing) | ||
105 | + ] | ||
106 | + : <NavigatorObserver>[ | ||
107 | + GetObserver(config.routingCallback, routing), | ||
108 | + ...config.navigatorObservers! | ||
109 | + ]), | ||
109 | ); | 110 | ); |
110 | 111 | ||
111 | routeInformationParser = config.routeInformationParser ?? | 112 | routeInformationParser = config.routeInformationParser ?? |
112 | createInformationParser( | 113 | createInformationParser( |
113 | - initialRoute: config.initialRoute ?? config.getPages?.first.name ?? cleanRouteName("/${config.home.runtimeType}"), | 114 | + initialRoute: config.initialRoute ?? |
115 | + config.getPages?.first.name ?? | ||
116 | + cleanRouteName("/${config.home.runtimeType}"), | ||
114 | ); | 117 | ); |
115 | 118 | ||
116 | if (config.locale != null) Get.locale = config.locale; | 119 | if (config.locale != null) Get.locale = config.locale; |
@@ -127,7 +130,6 @@ class GetMaterialController extends FullLifeCycleController { | @@ -127,7 +130,6 @@ class GetMaterialController extends FullLifeCycleController { | ||
127 | 130 | ||
128 | customTransition = config.customTransition; | 131 | customTransition = config.customTransition; |
129 | 132 | ||
130 | - //Get.setDefaultDelegate(routerDelegate); | ||
131 | Get.smartManagement = config.smartManagement; | 133 | Get.smartManagement = config.smartManagement; |
132 | config.onInit?.call(); | 134 | config.onInit?.call(); |
133 | 135 | ||
@@ -136,16 +138,14 @@ class GetMaterialController extends FullLifeCycleController { | @@ -136,16 +138,14 @@ class GetMaterialController extends FullLifeCycleController { | ||
136 | defaultTransition = config.defaultTransition ?? getThemeTransition(); | 138 | defaultTransition = config.defaultTransition ?? getThemeTransition(); |
137 | defaultOpaqueRoute = config.opaqueRoute ?? true; | 139 | defaultOpaqueRoute = config.opaqueRoute ?? true; |
138 | defaultPopGesture = config.popGesture ?? GetPlatform.isIOS; | 140 | defaultPopGesture = config.popGesture ?? GetPlatform.isIOS; |
139 | - defaultTransitionDuration = config.transitionDuration ?? Duration(milliseconds: 300); | ||
140 | - | ||
141 | - // defaultTransitionCurve = Curves.easeOutQuad; | ||
142 | - // defaultDialogTransitionCurve = Curves.easeOutQuad; | ||
143 | - // defaultDialogTransitionDuration = Duration(milliseconds: 300); | 141 | + defaultTransitionDuration = |
142 | + config.transitionDuration ?? Duration(milliseconds: 300); | ||
144 | } | 143 | } |
145 | 144 | ||
146 | - getThemeTransition() { | 145 | + Transition? getThemeTransition() { |
147 | final platform = Get.theme.platform; | 146 | final platform = Get.theme.platform; |
148 | - final matchingTransition = Get.theme.pageTransitionsTheme.builders[platform]; | 147 | + final matchingTransition = |
148 | + Get.theme.pageTransitionsTheme.builders[platform]; | ||
149 | switch (matchingTransition) { | 149 | switch (matchingTransition) { |
150 | case CupertinoPageTransitionsBuilder(): | 150 | case CupertinoPageTransitionsBuilder(): |
151 | return Transition.cupertino; | 151 | return Transition.cupertino; |
@@ -257,15 +257,14 @@ class GetMaterialController extends FullLifeCycleController { | @@ -257,15 +257,14 @@ class GetMaterialController extends FullLifeCycleController { | ||
257 | ); | 257 | ); |
258 | } | 258 | } |
259 | 259 | ||
260 | - // static GetDelegate? _delegate; | ||
261 | - | ||
262 | GetDelegate createDelegate({ | 260 | GetDelegate createDelegate({ |
263 | GetPage<dynamic>? notFoundRoute, | 261 | GetPage<dynamic>? notFoundRoute, |
264 | List<GetPage> pages = const [], | 262 | List<GetPage> pages = const [], |
265 | List<NavigatorObserver>? navigatorObservers, | 263 | List<NavigatorObserver>? navigatorObservers, |
266 | TransitionDelegate<dynamic>? transitionDelegate, | 264 | TransitionDelegate<dynamic>? transitionDelegate, |
267 | PopMode backButtonPopMode = PopMode.history, | 265 | PopMode backButtonPopMode = PopMode.history, |
268 | - PreventDuplicateHandlingMode preventDuplicateHandlingMode = PreventDuplicateHandlingMode.reorderRoutes, | 266 | + PreventDuplicateHandlingMode preventDuplicateHandlingMode = |
267 | + PreventDuplicateHandlingMode.reorderRoutes, | ||
269 | GlobalKey<NavigatorState>? navigatorKey, | 268 | GlobalKey<NavigatorState>? navigatorKey, |
270 | }) { | 269 | }) { |
271 | return GetDelegate( | 270 | return GetDelegate( |
@@ -47,8 +47,7 @@ void main() { | @@ -47,8 +47,7 @@ void main() { | ||
47 | 47 | ||
48 | await tester.pumpAndSettle(); | 48 | await tester.pumpAndSettle(); |
49 | 49 | ||
50 | - expect( | ||
51 | - GetMaterialController.to.rootDelegate.currentConfiguration?.route?.name, | 50 | + expect(Get.rootController.rootDelegate.currentConfiguration?.route?.name, |
52 | '/404'); | 51 | '/404'); |
53 | }); | 52 | }); |
54 | 53 |
-
Please register or login to post a comment