InjectedNavigator class
Injecting a Navigator 2 that holds a RouteData state.
final myNavigator = RM.injectNavigator(
routes: {
'/': (RouteData data) => HomePage(),
'/page1': (RouteData data) => Page1(),
},
);
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp.router(
routeInformationParser: myNavigator.routeInformationParser,
routerDelegate: myNavigator.routerDelegate,
);
}
}
See also RouteData and RouteWidget
Constructors
Properties
- canPop → bool
-
Whether a page can be popped off from the root route stack or sub route
stacks.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
-
getter/setter pair
-
Get an active navigation BuildContext.
no setter
-
pageStack
→ List<
PageSettings> -
Get the PageSettings stack.
no setter
- routeData → RouteData
-
Get the current RouteData
no setter
-
routeInformationParser
→ RouteInformationParser<
PageSettings> -
RouteInformationParser delegate.
no setter
-
routerConfig
→ RouterConfig<
PageSettings> -
RouterConfig delegate.
no setter
-
routerDelegate
→ RouterDelegate<
PageSettings> -
RouterDelegate implementation
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- scaffold → ScaffoldObject
-
Show ScaffoldMessenger related widgets such as SnackBar, Drawer, and
BottomSheets
no setter
Methods
-
back<
T extends Object> ([T? result]) → void - Navigate back to the last page, ie Pop the top-most route off the navigator.
-
backAndToNamed<
T extends Object?, TO extends Object?> (String routeName, {TO? result, Object? arguments, bool fullscreenDialog = false, bool maintainState = true}) → Future< T?> - Navigate back than to the page with the given named route
-
backUntil(
String untilRouteName) → void - Navigate back and remove all the previous routes until meeting the route with defined name
-
deepLinkTest(
String url) → void - Used in test to simulate a deep link call.
-
dispose(
) → void -
forceBack<
T extends Object> ([T? result]) → void -
Navigate Back by popping the top-most page route with all pagesless route
associated with it and without calling
onNavigateBack
hook. -
injectMock(
NavigationBuilder mock, {String? startRoute}) → void - Mock InjectedNavigator
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
Invoke
onNavigate
callback and navigate according the logic defined there. -
removePage<
T extends Object> (String routeName, [T? result]) → void - Remove a pages from the route stack.
-
setRouteStack(
List< PageSettings> stack(List<PageSettings> pages), {String? subRouteName}) → void - Set the route stack. It exposes the current PageSettings stack.
-
to<
T extends Object?> (String routeName, {Object? arguments, Map< String, String> ? queryParams, bool fullscreenDialog = false, bool maintainState = true, Widget builder(Widget route)?, Widget transitionsBuilder(BuildContext context, Animation<double> animation, Animation<double> secondAnimation, Widget child)?}) → Future<T?> - Find the page with given routeName and add it to the route stack and trigger route transition.
-
toAndRemoveUntil<
T extends Object?> (String newRouteName, {String? untilRouteName, Object? arguments, Map< String, String> ? queryParams, bool fullscreenDialog = false, bool maintainState = true}) → Future<T?> -
Find the page with given routeName and then remove all the previous routes
until meeting the route with defined route name
untilRouteName
. If no route name is given (untilRouteName
is null) , all routes will be removed except the new page route. -
toBottomSheet<
T> (Widget bottomSheet, {bool isDismissible = true, bool enableDrag = true, bool isScrollControlled = false, Color? backgroundColor, double? elevation, ShapeBorder? shape, Clip? clipBehavior, Color? barrierColor, bool postponeToNextFrame = false}) → Future< T?> - Shows a modal material design bottom sheet that prevents the user from interacting with the rest of the app.
-
toCupertinoDialog<
T> (Widget dialog, {bool barrierDismissible = false, bool postponeToNextFrame = false}) → Future< T?> - Displays an iOS-style dialog above the current contents of the app, with iOS-style entrance and exit animations, modal barrier color, and modal barrier behavior
-
toCupertinoModalPopup<
T> (Widget cupertinoModalPopup, {ImageFilter? filter, bool semanticsDismissible = false, bool postponeToNextFrame = false}) → Future< T?> - Shows a modal iOS-style popup that slides up from the bottom of the screen.
-
toDeeply(
String routeName, {Object? arguments, Map< String, String> ? queryParams, bool fullscreenDialog = false, bool maintainState = true}) → void - Deeply navigate to the given routeName. Deep navigation means that the root stack is cleaned and pages corresponding to sub paths are added to the stack.
-
toDialog<
T> (Widget dialog, {bool barrierDismissible = true, Color? barrierColor, bool useSafeArea = true, bool postponeToNextFrame = false}) → Future< T?> - Displays a Material dialog above the current contents of the app, with Material entrance and exit animations, modal barrier color, and modal barrier behavior (dialog is dismissible with a tap on the barrier).
-
toPageless<
T extends Object?> (Widget page, {String? name, bool fullscreenDialog = false, bool maintainState = true}) → Future< T?> - Push a pageless route
-
toReplacement<
T extends Object?, TO extends Object?> (String routeName, {TO? result, Object? arguments, Map< String, String> ? queryParams, bool fullscreenDialog = false, bool maintainState = true, Widget transitionsBuilder(BuildContext context, Animation<double> animation, Animation<double> secondAnimation, Widget child)?}) → Future<T?> - Find the page with given routeName and remove the current route and replace it with the new one.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited