named_routes 0.2.0 copy "named_routes: ^0.2.0" to clipboard
named_routes: ^0.2.0 copied to clipboard

discontinuedreplaced by: routerino
outdated

Add names to routes without a declarative design pattern and without build_runner

named_routes #

pub package License: MIT

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!

Overview #

NO to declaration of all routes aka go_router

NO to build_runner

YES to type-safety (we call widget constructors directly)

YES to sentry integration (named routes)

I just want to push a widget and that's it!

The problems without this package:

  1. Pushing a new route requires lots of boilerplate.
  2. Adding a name to the route requires you to write things twice (redundancy).
Navigator.push<T>(
  context,
  MaterialPageRoute(
    builder: (_) => LoginPage(),
    settings: RouteSettings(name: 'LoginPage'), // so redundant!
  ),
);

Now you only need to write:

context.push(() => LoginPage());

Usage #

// 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());

// pop the most recent route
context.pop();

Sentry #

You want it to look like this?

sentry

MaterialApp(
  navigatorObservers: [
    SentryNavigatorObserver(), // add this 
  ],
  home: const InitPage(),
);

Obfuscation #

It does not work if you obfuscate the classes.

It is up to you. I don't value obfuscation that much.

Compiled flutter code is already hard to read.

1
likes
0
points
3
downloads

Publisher

verified publishertienisto.com

Weekly Downloads

Add names to routes without a declarative design pattern and without build_runner

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter

More

Packages that depend on named_routes