APSNavigator class
The APS lib implementation of a RouterDelegate.
It:
- Creates an internal Navigator Widget and handles it's
Pages
updates. - Manages System Back Button events, popping
Pages
when needed. - Receives URLs from browsers, parses any params, and pushes the proper route.
How to use it:
// 1 - Creates a Navigator.
final navigator = APSNavigator.from(
routeBuilders: {
'/': HomePage.route,
'/posts/{post_id}': PostPage.route,
'/bottom_nav_2{?query_val1,query_val2,...}': BottomNavPage.route,
'...': ...
}
);
// 2 - Use it when creating a [Router]. Remember to include a [APSParser] too.
@override
Widget build(BuildContext context) {
return MaterialApp.router(
routeInformationParser: navigator.parser,
routerDelegate: navigator,
);
}
// 3 - Prepare your Widget to be used as a Route.
class HomePage extends StatefulWidget {
HomePage({Key? key}) : super(key: key);
@override
_HomePageState createState() => _HomePageState();
// You don't need to use a static method here, but it's a nice way of organizing things.
static Page route({Map<String, dynamic>? params}) {
// * Important: AVOID using 'const' keyword at "MaterialPage" or "HomePage" levels,
// * or Pop may not work properly with Web History
return MaterialPage(
key: const ValueKey('Home'), //* Important: Always include a key here!
child: HomePage(),
);
}
}
- Inheritance
-
- Object
- Listenable
- RouterDelegate<
ApsParserData> - APSNavigator
Constructors
-
Creates and configures a new APSNavigator instance properly.
factory
Properties
- backButtonDispatcher ↔ BackButtonDispatcher?
-
Should be used when creating a child navigator.
getter/setter pair
- controller → APSController
-
final
- currentConfiguration → ApsParserData?
-
Called by the Router when it detects a route information may have
changed as a result of rebuild.
no setteroverride
- hashCode → int
-
The hash code for this object.
no setterinherited
-
final
- parser → APSParser
-
Default APSParser used by all APSNavigator instances.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
addListener(
dynamic listener()) → void -
Register a closure to be called when the object notifies its listeners.
override
-
build(
BuildContext context) → Widget -
Called by the Router to obtain the widget tree that represents the
current state.
override
-
interceptBackButton(
BuildContext context) → void - Makes this navigator intercept Back Button Events.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
popRoute(
) → Future< bool> -
Called by the Router when the Router.backButtonDispatcher reports that
the operating system is requesting that the current route be popped.
override
-
removeListener(
dynamic listener()) → void -
Remove a previously registered closure from the list of closures that the
object notifies.
override
-
setInitialRoutePath(
ApsParserData configuration) → Future< void> -
Called by the Router at startup with the structure that the
RouteInformationParser obtained from parsing the initial route.
override
-
setNewRoutePath(
ApsParserData configuration) → Future< void> -
Called by the Router when the Router.routeInformationProvider reports that a
new route has been pushed to the application by the operating system.
override
-
setRestoredRoutePath(
ApsParserData configuration) → Future< void> -
Called by the Router during state restoration.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
of(
BuildContext context) → APSController -
Returns the APSController instance closest
context
.