Showing
7 changed files
with
17 additions
and
10 deletions
| 1 | import 'package:flutter/foundation.dart'; | 1 | import 'package:flutter/foundation.dart'; |
| 2 | import 'package:flutter/scheduler.dart'; | 2 | import 'package:flutter/scheduler.dart'; |
| 3 | 3 | ||
| 4 | +import '../../get.dart'; | ||
| 5 | + | ||
| 4 | /// The [GetLifeCycle] | 6 | /// The [GetLifeCycle] |
| 5 | /// | 7 | /// |
| 6 | /// ```dart | 8 | /// ```dart |
| @@ -16,7 +18,8 @@ mixin GetLifeCycleMixin { | @@ -16,7 +18,8 @@ mixin GetLifeCycleMixin { | ||
| 16 | @protected | 18 | @protected |
| 17 | @mustCallSuper | 19 | @mustCallSuper |
| 18 | void onInit() { | 20 | void onInit() { |
| 19 | - SchedulerBinding.instance?.addPostFrameCallback((_) => onReady()); | 21 | + ambiguate(SchedulerBinding.instance) |
| 22 | + ?.addPostFrameCallback((_) => onReady()); | ||
| 20 | } | 23 | } |
| 21 | 24 | ||
| 22 | /// Called 1 frame after onInit(). It is the perfect place to enter | 25 | /// Called 1 frame after onInit(). It is the perfect place to enter |
| @@ -358,7 +358,7 @@ extension ExtensionSnackbar on GetInterface { | @@ -358,7 +358,7 @@ extension ExtensionSnackbar on GetInterface { | ||
| 358 | if (instantInit) { | 358 | if (instantInit) { |
| 359 | controller.show(); | 359 | controller.show(); |
| 360 | } else { | 360 | } else { |
| 361 | - SchedulerBinding.instance!.addPostFrameCallback((_) { | 361 | + ambiguate(SchedulerBinding.instance)!.addPostFrameCallback((_) { |
| 362 | controller.show(); | 362 | controller.show(); |
| 363 | }); | 363 | }); |
| 364 | } | 364 | } |
| @@ -469,7 +469,7 @@ extension ExtensionSnackbar on GetInterface { | @@ -469,7 +469,7 @@ extension ExtensionSnackbar on GetInterface { | ||
| 469 | controller.show(); | 469 | controller.show(); |
| 470 | } else { | 470 | } else { |
| 471 | //routing.isSnackbar = true; | 471 | //routing.isSnackbar = true; |
| 472 | - SchedulerBinding.instance!.addPostFrameCallback((_) { | 472 | + ambiguate(SchedulerBinding.instance)!.addPostFrameCallback((_) { |
| 473 | controller.show(); | 473 | controller.show(); |
| 474 | }); | 474 | }); |
| 475 | } | 475 | } |
| @@ -52,7 +52,7 @@ class RouterReportManager<T> { | @@ -52,7 +52,7 @@ class RouterReportManager<T> { | ||
| 52 | 52 | ||
| 53 | void reportRouteDispose(T disposed) { | 53 | void reportRouteDispose(T disposed) { |
| 54 | if (Get.smartManagement != SmartManagement.onlyBuilder) { | 54 | if (Get.smartManagement != SmartManagement.onlyBuilder) { |
| 55 | - WidgetsBinding.instance!.addPostFrameCallback((_) { | 55 | + ambiguate(WidgetsBinding.instance)!.addPostFrameCallback((_) { |
| 56 | _removeDependencyByRoute(disposed); | 56 | _removeDependencyByRoute(disposed); |
| 57 | }); | 57 | }); |
| 58 | } | 58 | } |
| @@ -449,7 +449,7 @@ You need to either use message[String], or messageText[Widget] or define a userI | @@ -449,7 +449,7 @@ You need to either use message[String], or messageText[Widget] or define a userI | ||
| 449 | } | 449 | } |
| 450 | 450 | ||
| 451 | void _configureLeftBarFuture() { | 451 | void _configureLeftBarFuture() { |
| 452 | - SchedulerBinding.instance!.addPostFrameCallback( | 452 | + ambiguate(SchedulerBinding.instance)!.addPostFrameCallback( |
| 453 | (_) { | 453 | (_) { |
| 454 | final keyContext = _backgroundBoxKey.currentContext; | 454 | final keyContext = _backgroundBoxKey.currentContext; |
| 455 | if (keyContext != null) { | 455 | if (keyContext != null) { |
| @@ -96,13 +96,13 @@ mixin FullLifeCycleMixin on FullLifeCycleController { | @@ -96,13 +96,13 @@ mixin FullLifeCycleMixin on FullLifeCycleController { | ||
| 96 | @override | 96 | @override |
| 97 | void onInit() { | 97 | void onInit() { |
| 98 | super.onInit(); | 98 | super.onInit(); |
| 99 | - WidgetsBinding.instance!.addObserver(this); | 99 | + ambiguate(WidgetsBinding.instance)!.addObserver(this); |
| 100 | } | 100 | } |
| 101 | 101 | ||
| 102 | @mustCallSuper | 102 | @mustCallSuper |
| 103 | @override | 103 | @override |
| 104 | void onClose() { | 104 | void onClose() { |
| 105 | - WidgetsBinding.instance!.removeObserver(this); | 105 | + ambiguate(WidgetsBinding.instance)!.removeObserver(this); |
| 106 | super.onClose(); | 106 | super.onClose(); |
| 107 | } | 107 | } |
| 108 | 108 |
| @@ -3,6 +3,7 @@ import 'dart:async'; | @@ -3,6 +3,7 @@ import 'dart:async'; | ||
| 3 | import 'package:flutter/scheduler.dart'; | 3 | import 'package:flutter/scheduler.dart'; |
| 4 | import 'package:flutter/widgets.dart'; | 4 | import 'package:flutter/widgets.dart'; |
| 5 | 5 | ||
| 6 | +import '../../../get_core/src/typedefs.dart'; | ||
| 6 | import 'list_notifier.dart'; | 7 | import 'list_notifier.dart'; |
| 7 | 8 | ||
| 8 | typedef ValueBuilderUpdateCallback<T> = void Function(T snapshot); | 9 | typedef ValueBuilderUpdateCallback<T> = void Function(T snapshot); |
| @@ -102,13 +103,14 @@ mixin ObserverComponent on ComponentElement { | @@ -102,13 +103,14 @@ mixin ObserverComponent on ComponentElement { | ||
| 102 | 103 | ||
| 103 | Future<bool> _safeRebuild() async { | 104 | Future<bool> _safeRebuild() async { |
| 104 | if (dirty) return false; | 105 | if (dirty) return false; |
| 105 | - if (SchedulerBinding.instance == null) { | 106 | + if (ambiguate(SchedulerBinding.instance) == null) { |
| 106 | markNeedsBuild(); | 107 | markNeedsBuild(); |
| 107 | } else { | 108 | } else { |
| 108 | // refresh was called during the building | 109 | // refresh was called during the building |
| 109 | - if (SchedulerBinding.instance!.schedulerPhase != SchedulerPhase.idle) { | 110 | + if (ambiguate(SchedulerBinding.instance)!.schedulerPhase |
| 111 | + != SchedulerPhase.idle) { | ||
| 110 | // Await for the end of build | 112 | // Await for the end of build |
| 111 | - await SchedulerBinding.instance!.endOfFrame; | 113 | + await ambiguate(SchedulerBinding.instance)!.endOfFrame; |
| 112 | if (dirty) return false; | 114 | if (dirty) return false; |
| 113 | } | 115 | } |
| 114 | 116 |
-
Please register or login to post a comment