Committed by
GitHub
Merge pull request #2156 from CaLouro/null-safe-Get.engine
Null safe Get.engine
Showing
3 changed files
with
6 additions
and
9 deletions
| @@ -1059,7 +1059,7 @@ extension GetNavigationExt on GetInterface { | @@ -1059,7 +1059,7 @@ extension GetNavigationExt on GetInterface { | ||
| 1059 | /// Your entire application will be rebuilt, and touch events will not | 1059 | /// Your entire application will be rebuilt, and touch events will not |
| 1060 | /// work until the end of rendering. | 1060 | /// work until the end of rendering. |
| 1061 | Future<void> forceAppUpdate() async { | 1061 | Future<void> forceAppUpdate() async { |
| 1062 | - await engine!.performReassemble(); | 1062 | + await engine.performReassemble(); |
| 1063 | } | 1063 | } |
| 1064 | 1064 | ||
| 1065 | void appUpdate() => _getxController.update(); | 1065 | void appUpdate() => _getxController.update(); |
| @@ -1173,12 +1173,9 @@ extension GetNavigationExt on GetInterface { | @@ -1173,12 +1173,9 @@ extension GetNavigationExt on GetInterface { | ||
| 1173 | return _theme; | 1173 | return _theme; |
| 1174 | } | 1174 | } |
| 1175 | 1175 | ||
| 1176 | - ///The current [WidgetsBinding] | ||
| 1177 | - WidgetsBinding? get engine { | ||
| 1178 | - if (WidgetsBinding.instance == null) { | ||
| 1179 | - WidgetsFlutterBinding(); | ||
| 1180 | - } | ||
| 1181 | - return WidgetsBinding.instance; | 1176 | + /// The current null safe [WidgetsBinding] |
| 1177 | + WidgetsBinding get engine { | ||
| 1178 | + return WidgetsFlutterBinding.ensureInitialized(); | ||
| 1182 | } | 1179 | } |
| 1183 | 1180 | ||
| 1184 | /// The window to which this binding is bound. | 1181 | /// The window to which this binding is bound. |
| @@ -199,7 +199,7 @@ class GetCupertinoApp extends StatelessWidget { | @@ -199,7 +199,7 @@ class GetCupertinoApp extends StatelessWidget { | ||
| 199 | Get.routeInformationParser = null; | 199 | Get.routeInformationParser = null; |
| 200 | }, | 200 | }, |
| 201 | initState: (i) { | 201 | initState: (i) { |
| 202 | - Get.engine!.addPostFrameCallback((timeStamp) { | 202 | + Get.engine.addPostFrameCallback((timeStamp) { |
| 203 | onReady?.call(); | 203 | onReady?.call(); |
| 204 | }); | 204 | }); |
| 205 | if (locale != null) Get.locale = locale; | 205 | if (locale != null) Get.locale = locale; |
| @@ -215,7 +215,7 @@ class GetMaterialApp extends StatelessWidget { | @@ -215,7 +215,7 @@ class GetMaterialApp extends StatelessWidget { | ||
| 215 | initState: (i) { | 215 | initState: (i) { |
| 216 | // Get.routerDelegate = routerDelegate; | 216 | // Get.routerDelegate = routerDelegate; |
| 217 | // Get.routeInformationParser = routeInformationParser; | 217 | // Get.routeInformationParser = routeInformationParser; |
| 218 | - Get.engine!.addPostFrameCallback((timeStamp) { | 218 | + Get.engine.addPostFrameCallback((timeStamp) { |
| 219 | onReady?.call(); | 219 | onReady?.call(); |
| 220 | }); | 220 | }); |
| 221 | if (locale != null) Get.locale = locale; | 221 | if (locale != null) Get.locale = locale; |
-
Please register or login to post a comment