AppRouter class
A central router class that manages app navigation, route matching, authorization checks, redirects, and unknown route handling.
Use init to set up global route definitions and routes.
The class provides methods to generate routes dynamically based on RouteSettings, including authorization and redirection logic.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
- initialRoute → String
-
Returns the initial route defined in the global route definer.
no setter
-
routes
← List<
RouteDefiner> -
Sets the list of route definitions for the app.
no getter
- title → String
-
Returns the app's title from the global route definer.
no setter
Static Methods
-
analyzeRoute(
RouteSettings settings) → ({bool isNear, RouteDefiner? match, RouteState state}) - Analyzes RouteSettings by building the RouteState and matching it against routes.
-
buildRouteState(
RouteSettings settings) → RouteState - Builds a RouteState object from RouteSettings, parsing path, query parameters, fragment, and arguments.
-
extractPathParams(
String pattern, String actual) → Map< String, String> ? -
Extracts dynamic path parameters from a route
pattern
using the actualactual
path. -
init(
GlobalRouteDefiner definer, List< RouteDefiner> routeList) → void - Initializes the router with a GlobalRouteDefiner and a list of RouteDefiner routes.
-
isNearMatch(
String routePattern, String path) → bool -
Returns true if
path
is a near match to the route patternroutePattern
. -
matchRoute(
String path) → (RouteDefiner?, bool) -
Matches a given
path
against the list of registered routes. -
onGenerateRoute(
RouteSettings settings) → Route? - Generates a route based on the provided RouteSettings.
-
onUnknownRoute(
RouteSettings settings) → Route? - Handles unknown routes (e.g., 404) based on RouteSettings.