router_management 1.2.2

  • Readme
  • Changelog
  • Installing
  • new47

Flutter Router #

A Router Management

Instructions #

Define your Route Management class

class AppRoutes {

  //A controller to manage the app routes
  static final router = RouterController();

  //Variables that contains screen's name
  static const intro = '/';

  static const home = '/home';

  //Function that add routes to RouterController manage routes
  static void setRoutes() {
    //Create app routes
      //Screen name
      (context) => IntroScreen(),
      //Define if the screen will be a fullscreenDialog (Default false)
      fullscreenDialog: false,
      //Define a custom transition duration. Native transitions won't be affected (Default 250 milliseconds)
      transitionDuration: const Duration(milliseconds: 300),
      //Define a custom transition. A custom transition only works if useNativeTransitions is false or the platform is Web (Default right to left with fade in)
      transitionsBuilder: (
        BuildContext context,
        Animation<double> animation,
        Animation<double> secondaryAnimation,
        Widget child,
      ) {
        return FadeTransition(
          opacity: animation,
          child: child,
      //Define if you want or don't want use native transitions (Default true)
      useNativeTransitions: !kIsWeb || Platform.isIOS,

Configure your MaterialApp

class App extends StatefulWidget {
  _AppState createState() => _AppState();

class _AppState extends State<App> {
  void initState() {
    //initialize the routes

  Widget build(BuildContext context) {
    return MaterialApp(
      //Initialize the generator into a material app
      onGenerateRoute: AppRoutes.router.onGenerateRoute,
      //Define the app initial route
      initialRoute: AppRoutes.intro,

void main() => runApp(App());
//Navigate to your named screen with params
Map<String,dynamic> params = <String,dynamic>{};
Navigator.pushNamed(context, AppRoutes.home, arguments: params);
Navigator.pushReplacementNamed(context, AppRoutes.home, arguments: params);

//Get params in the build
Widget build(BuildContext context) {
  final Map<String,dynamic> params = ModalRoute.of(context).settings.arguments;
  return Container(

//Get params in the didChangeDependencies
void didChangeDependencies() {
  final Map<String,dynamic> params = ModalRoute.of(context).settings.arguments;

[1.2.2] - Added shadow to custom transition #

  • Optimized the custom transition with a shadow during the transition between screens

[1.1.1] - Breaking Changes and Bug Fixes #

  • Optimized the custom transition and created compatibility with newer Flutter Versions
  • Now to add a route you need to change from Router.define to Router.addRoute
  • Changed property nativeTransition to useNativeTransitions
  • The plugins does not support initial route anymore for compatibility with newer versions and web
  • Fixed a bug that arguments was null
  • Fixed a bug on some versions of flutter that was not generating new routes

[1.0.0] - Initial Release. #

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  router_management: ^1.2.2

2. Install it

You can install packages from the command line:

with Flutter:

$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:router_management/router_management.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Apr 7, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.6
  • Flutter: 1.12.13+hotfix.8

Health issues and suggestions

Document public APIs. (-1 points)

5 out of 5 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.

Fix lib/src/router_controller.dart. (-0.50 points)

Analysis of lib/src/router_controller.dart reported 1 hint:

line 29 col 9: This function has a return type of 'Route', but doesn't end with a return statement.

Maintenance suggestions

The package description is too short. (-20 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Maintain an example. (-10 points)

Create a short demo in the example/ directory to show how to use this package.

Common filename patterns include main.dart, example.dart, and router_management.dart. Packages with multiple examples should provide example/

For more information see the pub package layout conventions.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.8
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies