named_routes 0.0.1
named_routes: ^0.0.1 copied to clipboard
Add names to routes without a declarative design pattern
named_routes #
This opinionated package provides extension methods for BuildContext to push routes.
...and automatically add a name to the route so you can track it in sentry!
Motivation #
I don't like to manually declare all routes and just push a widget and that's it!
The problems:
- Pushing a new route requires lots of boilerplate.
- I want to add some name to the route in order to track it in sentry.
Navigator.push<T>(
context,
MaterialPageRoute(
builder: (_) => LoginPage(),
settings: RouteSettings(name: 'LoginPage'), // so redundant!
),
);
Usage #
Pushing a route:
// push a new route
context.push(() => MyPage());
// push a route while removing all others
context.pushRoot(() => MyPage());
// push a route while removing all others (without animation)
context.pushRootNoAnimation(() => MyPage());
Sentry #
You want it to look like this?
[sentry]
MaterialApp(
navigatorObservers: [
SentryNavigatorObserver(), // add this
],
home: const InitPage(),
);