Browse Source

add FluroRouter.navigateTo(.rootNavigator, .nullOk)

lukepighetti 5 năm trước cách đây
mục cha
commit
4a1506d6ec
1 tập tin đã thay đổi với 7 bổ sung4 xóa
  1. 7 4
      lib/src/fluro_router.dart

+ 7 - 4
lib/src/fluro_router.dart

@@ -52,6 +52,8 @@ class FluroRouter {
       {bool replace = false,
       bool clearStack = false,
       bool maintainState = true,
+      bool rootNavigator = false,
+      bool nullOk = false,
       TransitionType transition,
       Duration transitionDuration,
       RouteTransitionsBuilder transitionBuilder,
@@ -72,13 +74,14 @@ class FluroRouter {
         route = _notFoundRoute(context, path, maintainState: maintainState);
       }
       if (route != null) {
+        final navigator =
+            Navigator.of(context, rootNavigator: rootNavigator, nullOk: nullOk);
         if (clearStack) {
-          future =
-              Navigator.of(context).pushAndRemoveUntil(route, (check) => false);
+          future = navigator.pushAndRemoveUntil(route, (check) => false);
         } else {
           future = replace
-              ? Navigator.of(context).pushReplacement(route)
-              : Navigator.of(context).push(route);
+              ? navigator.pushReplacement(route)
+              : navigator.push(route);
         }
         completer.complete();
       } else {