simple_router 0.1.0+1

Flutter Android iOS web

A simple router for flutter to navigate beetween screens without the need of the context. This package also provides middleware capabilities on route transitions.

example #

A new Flutter project.

Using #

The easiest way to use the router is to set the navigatorKey provided by the Router to the material app. Using that you can navigate from anywhere on your app (including places that don't have a BuildContext), including BloC's (not saying you have to do that by any means).

class MyApp extends StatelessWidget {  
  @override  
  Widget build(BuildContext context) {  
      return MaterialApp(  
          navigatorKey: SimpleRouter.getKey(),  
          title: 'Flutter Demo',  
          theme: ThemeData(  
              primarySwatch: Colors.blue,  
          ),  
          home: MyHomePage(title: 'Flutter Router Example'),  
      );  
  }  
}

Another great thing you can do is implement to functions of the Router: onBeforePush and onAfterPush, those functions are called before and after the navigation occurs. They are good to implement some kind of logging when entering or leaving the page for example.

You can choose beetwen Material or Cupertino transitions. To pick cupertino just set the useCupertinoTransition of the SimpleRouter to true (default is false).

1
likes
110
pub points
51%
popularity

A simple router for flutter to navigate beetween screens without the need of the context. This package also provides middleware capabilities on route transitions.

Repository (GitHub)
View/report issues

Documentation

API reference

Uploader

rodrigobastosv@gmail.com

License

BSD (LICENSE)

Dependencies

flutter

More

Packages that depend on simple_router