RouteContext<T> class

Immutable context passed to route guards.

Contains all information about the navigation request. Use copyWith or withData to create modified copies.

Example:

@override
Future<GuardResult> onBefore(RouteContext context) async {
  print('Navigating to: ${context.routeName}');
  print('Query params: ${context.queryParameters}');
  return next();
}

Constructors

RouteContext({BuildContext? context, T? data, Map<String, String> queryParameters = const {}, required String routeName, String? originalRouteName})
const

Properties

context BuildContext?
The current build context, if available.
final
data → T?
The data passed to this route.
final
hashCode int
The hash code for this object.
no setterinherited
originalRouteName String?
The original route name before any transformations.
final
queryParameters Map<String, String>
Query parameters from the URL.
final
routeName String
The name/path of the route being navigated to.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

copyWith({BuildContext? context, T? data, Map<String, String>? queryParameters, String? routeName, String? originalRouteName}) RouteContext<T>
Create a copy with some fields changed.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited
withData<R>(R newData) RouteContext<R>
Create a copy with different data.

Operators

operator ==(Object other) bool
The equality operator.
inherited