Flutter self made plug-in R_ Router does not need context routing plug-in

Time:2021-7-26

Flutter self made plug-in R_ Router does not need context routing plug-in

r_router

A fluent routing plug-in that does not require context navigation and supports dialog

.———————————————-

|GitHub address:

| https://github.com/rhymelph/r…

|Pub address:

| https://pub.dev/packages/r_ro…

`———————————————-

1. Start using

  • pubspec.yamlFile add dependency
dependencies:
  r_router: last version
  • Import package
import 'package:r_router/r_router.dart';

2. Simple use

  • Register routing
///[path] your routing path
///[routerwidgetbuilder] build your page
///[params] your parameter supports all types of values. The type is dynamic
///[PAGEONE] your part
RRouter.myRouter.addRouter(
    path: '/one',
    routerWidgetBuilder: (params) => PageOne(title:params["title"]),
  );
  • Add your route to 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 the registered page
    RRouter.myRouter.navigateTo('/one', arguments: {'title': 'hello world!'});

3. Register routing

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

///Register the route with transition animation. The default is the transition animation according to the corresponding platform, IOS: cupertinopageroute, Android: materialpageroute
RRouter.myRouter.addRouter(
      path: '/three',
      routerWidgetBuilder: (params) => PageThree(),
      routerPageBuilder: (RouteSettings setting, WidgetBuilder builder) =>
          CupertinoPageRoute(builder: builder, settings: setting))

4. Display dialog box method without context

The following methods are supported

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

5. Default router

You can use the following code for route jump

RRouter.navigator