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

hashCode int
The hash code for this object.
no setterinherited
routes Map<String, PageRouteBuilder>
The application's top-level routing table.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

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