flutter_page_router 0.1.0

  • Readme
  • Changelog
  • Example
  • Installing
  • 51

flutter_page_router #

A front-end develop-oriented Routing Manage library that route params, context less programmatic navigation and global hooks.


README in Chinese

Features: #

  • Modular, component-based router configuration
  • Route params
  • View transition effects(dependent on flutter_page_transition
  • Context less programmatic navigation
  • Global hooks

Getting Started #

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

  flutter_page_router: ^0.1.0

You can also depend on this package stored in my repository:

    url: git://github.com/handoing/flutter_page_router.git

You should then run flutter packages upgrade.

Example: #

FlutterPageRouter routerInit () {

  // Define some routes
  List routes = [
      r.name: 'home', // Define route name
      r.component: (params) => HomePage() // Define route component
      r.name: 'other',
      r.transitionType: PageTransitionType.slideInRight, // Define route transition type
      r.component: (params) {
        return new FutureBuilder<String>(
          future: Future.delayed(Duration(milliseconds: 1000)),
          builder: (BuildContext context, AsyncSnapshot<String> snapshot) {
            switch (snapshot.connectionState) {
              case ConnectionState.done: return OtherPage(id: params['id']);
              case ConnectionState.none: return LoadingPage();
              case ConnectionState.waiting: return LoadingPage();
                return new Text('Error: ${snapshot.error}');
      r.type: RouterType.NotFound, // Define not found
      r.transitionHandle: (Curve curve, Animation<double> animation, Animation<double> secondaryAnimation, Widget child) {
        return new SlideTransition(
          position: new Tween<Offset>(
            begin: const Offset(1.0, 0.0),
            end: const Offset(0.0, 0.0),
          ).animate(CurvedAnimation(parent: animation, curve: curve)),
          child: child,
      }, // Define route transition handle
      r.component: (params) => NotFoundPage()

  // Create the router instance
  FlutterPageRouter router = FlutterPageRouter(
      routes: routes

  // Define global before hooks
  router.globalBeforeRouteUpdate((name, params, child) {
    // Requests PV can be sent uniformly, or wrap a logic component and so on
    return Container(
      child: child,

  return router;

class MyApp extends StatelessWidget {
  Widget build(BuildContext context) {

    FlutterPageRouter router = routerInit(); // Initialization Router

    return MaterialApp(
      title: 'Flutter',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      initialRoute: 'home',
      navigatorKey: router.navKey, // Define navigator Key, used to internally capture context
      onGenerateRoute: router.generator // Define generator

void main() => runApp(MyApp());

PageRouterNav #

flutter_page_router provides a PageRouterNav for developers to route navigation operations, it's internal use is still Navigator, call a variety of navigation operations provided by Navigator, such as push, pushNamed, pop, etc. The convenience of PageRouterNav is that there is no need to pass in the context. for example:


// or

PageRouterNav.pushNamed('other', params: {
 'id': 666

Test #

run test

flutter test

Test Driver #

run driver test

cd example/
flutter drive --target=test_driver/app.dart

License #


[0.1.0] - Update READEME.

  • update READEME.md.
  • add example.

[0.0.3] - Update Source.

  • update source.
  • update README.md.

[0.0.2] - Update Source.

  • update source.
  • update README.md.
  • require dependencies.

[0.0.1] - Init Package.

  • init package.


example #

A new Flutter application.

Getting Started #

This project is a starting point for a Flutter application.

A few resources to get you started if this is your first Flutter project:

For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.

Use this package as a library

1. Depend on it

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

  flutter_page_router: ^0.1.0

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:flutter_page_router/flutter_page_router.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 Jan 16, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.0
  • pana: 0.13.4
  • Flutter: 1.12.13+hotfix.5

Health issues and suggestions

Document public APIs. (-0.40 points)

96 out of 98 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.

Format lib/common_type.dart.

Run flutter format to format lib/common_type.dart.

Format lib/flutter_page_router.dart.

Run flutter format to format lib/flutter_page_router.dart.

Format lib/navigate_service.dart.

Run flutter format to format lib/navigate_service.dart.

Format lib/page_router_nav.dart.

Run flutter format to format lib/page_router_nav.dart.

Format lib/route_observer.dart.

Run flutter format to format lib/route_observer.dart.

Maintenance issues and suggestions

Support latest dependencies. (-10 points)

The version constraint in pubspec.yaml does not support the latest published versions for 1 dependency (get_it).


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
flutter_page_transition ^0.1.0 0.1.6
get_it ^1.0.3+2 1.1.0 3.1.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