r_router 0.1.3

  • Readme
  • Changelog
  • Example
  • Installing
  • 55

r_router #

pub package

A Flutter router package,you can not need use context to navigate,and support dialog.

中文点此 #

1.Getting Started. #

  • use plugin: add this code in pubspec.yaml
dependencies:
  r_router: last version
  • add the packages to your file.
import 'package:r_router/r_router.dart';

2.Simple use #

  • register router
/// [path] your router path.
/// [routerWidgetBuilder] build your widget.
/// [params] your params , support all value.
/// [PageOne] your page.
RRouter.myRouter.addRouter(
    path: '/one',
    routerWidgetBuilder: (params) => PageOne(title:params["title"]),
  );

  • add the router in app.
class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      // add new
      onGenerateRoute: RRouter.myRouter.routerGenerate,
      navigatorObservers: [
        RRouter.myRouter.observer,
      ],
      // add new
      home: MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

  • navigate to it.
    RRouter.myRouter.navigateTo('/one', arguments: {'title': 'hello world!'});

3.Register router #


/// register not found page
RRouter.myRouter.notFoundPage = (String path) => NoFoundPage(
        path: path,
      );

/// set page build transform ,default platform page transform
RRouter.myRouter.addRouter(
      path: '/three',
      routerWidgetBuilder: (params) => PageThree(),
      routerPageBuilder: (RouteSettings setting, WidgetBuilder builder) =>
          CupertinoPageRoute(builder: builder, settings: setting))

4. Not context show dialog #

support as follows method

  • showRDialog
  • showRCupertinoDialog
  • showRCupertinoModalPopup
  • showRAboutDialog
  • showRMenu
  • showRTimePicker
  • showRGeneralDialog
  • showRDatePicker
  • showRSearch
  • showRModalBottomSheet
  • showRLicensePage

5.Default Navigator #

you can use

RRouter.navigator

一个无需使用context导航的Flutter路由插件,支持dialog

[0.1.3] - add pop 、popAndPushNamed 、popUntil 、canPop 、maybePop method #

[0.1.2] - format #

[0.1.1] - format #

[0.1.0] - add dialog method. #

[0.0.1] - init project #

example/lib/main.dart

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:r_router/r_router.dart';
import 'package:r_router_example/src/page/404_page.dart';
import 'src/page/my_page.dart';
import 'src/page/page_one.dart';
import 'src/page/page_three.dart';
import 'src/page/page_two.dart';

void main() {
  initRouter();
  runApp(MyApp());
}

void initRouter() {
  // add new
  RRouter.myRouter.addRouter(
    path: '/one',
    routerWidgetBuilder: (params) => PageOne(),
  );
  RRouter.myRouter.addRouter(
    path: '/two',
    routerWidgetBuilder: (params) => PageTwo(
      param: params['param'],
    ),
  );
  RRouter.myRouter.addRouter(
      path: '/three',
      routerWidgetBuilder: (params) => PageThree(),
      routerPageBuilder: (RouteSettings setting, WidgetBuilder builder) =>
          CupertinoPageRoute(builder: builder, settings: setting));
  RRouter.myRouter.notFoundPage = (String path) => NoFoundPage(
        path: path,
      );

  // add new
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      // add new
      onGenerateRoute: RRouter.myRouter.routerGenerate,
      navigatorObservers: [
        RRouter.myRouter.observer,
      ],
      // add new
      home: MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}
// use navigate
// RRouter.myRouter.navigateTo('/three', arguments: {'pageThree': 'hello world!'});

Use this package as a library

1. Depend on it

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


dependencies:
  r_router: ^0.1.3

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:r_router/r_router.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
10
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
55
Learn more about scoring.

We analyzed this package on Mar 27, 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

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.3.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
flutter_test