BetterRouter class
The BetterRouter class are resposible create the routing table and the route generator.
To simple routes is better use the routes params in MaterialApp:
BetterRouter(routes: {
"/": DefaultPageRouteBuilder((_)=> SomeScreen());
})
The good use case to BetterRouter is complex routes with params in path.
BetterRouter(routes: {
r"\/books\/(?<id>.+)": DefaultPageRouteBuilder((context) {
final params =
ModalRoute.of(context)!.settings.arguments as Map<String, String?>;
return Text("Book ID: ${params['id']}")]
});
})
Constructors
-
BetterRouter({required Map<
String, PageRouteBuilder> routes}) -
Create a new BetterRouter instance with the given
routes
Properties
Methods
-
call(
RouteSettings settings) → Route - The call method should be used as RouteFactory, per exemple, in the MaterialApp.onGenerateRoute or MaterialApp.onUnknownRoute params.
-
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