ff_annotation_route 2.0.3

ff_annotation_route #

pub package GitHub stars GitHub forks GitHub license GitHub issues flutter-candies

Languages: English | 中文简体

Description #

Provide a route generator to create route map quickly by annotations.

Usage #

Add packages to dev_dependencies #

Add the package to dev_dependencies in your project/packages's pubspec.yaml

dev_dependencies:
  ff_annotation_route: latest-version

Download with flutter packages get

Add annotation #

Empty Constructor #

import 'package:ff_annotation_route/ff_annotation_route.dart';

@FFRoute(
  name: "fluttercandies://mainpage",
  routeName: "MainPage",
)
class MainPage extends StatelessWidget 
{
  // ...
}

Constructor with arguments #

import 'package:ff_annotation_route/ff_annotation_route.dart';

@FFRoute(
  name: "fluttercandies://picswiper",
  routeName: "PicSwiper",
  argumentNames: ["index", "pics"],
  showStatusBar: false,
  pageRouteType: PageRouteType.transparent,
)
class PicSwiper extends StatefulWidget {
  final int index;
  final List<PicSwiperItem> pics;
  PicSwiper({this.index, this.pics});
  // ...
}

FFRoute #

ParameterDescriptionDefault
nameThe name of the route (e.g., "/settings").required
argumentNamesArguments name passed to FFRoute. Pass with double quote (") only.-
showStatusBarWhether to show the status bar.true
routeNameThe route name to track page.''
pageRouteTypeThe type of page route.(material, cupertino, transparent)-
descriptionThe description of the route.''

Generate Route File #

Environment #

Add dart bin into to your $PATH.

cache\dart-sdk\bin

More info

Activate the plugin #

pub global activate ff_annotation_route

Execute command #

Go to your project's root and execute command.

ff_route <command> [arguments]

Command Parameter #

Available commands:

-h , --help                         Print this usage information.

-p , --path [arguments]    The path of folder to be executed with commands.

-rc, --route-constants       Whether generate route names as constants.

-rh, --route-helper            Whether generate xxx_route_helper.dart

-rn, --route-names            Whether generate route names as a list.

-s , --save                          Whether save commands in local, it will read commands from local next time to execute if run "ff_route" without any commands.

-na, --no-arguments         Whether RouteSettings has arguments(for lower flutter sdk).

Main.dart #

  • If you execute command with --route-helper, FFNavigatorObserver/FFRouteSettings will generate in xxx_route_helper.dart which help you to track page or change status bar state.

  • If you execute command with --route-helper, FFTransparentPageRoute will generate in xxx_route_helper.dart which helps you to push a transparent page route.

Widget build(BuildContext context) {
    return OKToast(
        child: MaterialApp(
      title: 'ff_annotation_route demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      navigatorObservers: [
        FFNavigatorObserver(routeChange:
            (RouteSettings newRouteSettings, RouteSettings oldRouteSettings) {
          //you can track page here
          print(
              "route change: ${oldRouteSettings?.name} => ${newRouteSettings?.name}");
          if (newRouteSettings is FFRouteSettings &&
              oldRouteSettings is FFRouteSettings) {
            if (newRouteSettings?.showStatusBar !=
                oldRouteSettings?.showStatusBar) {
              if (newRouteSettings?.showStatusBar == true) {
                SystemChrome.setEnabledSystemUIOverlays(
                    SystemUiOverlay.values);
                SystemChrome.setSystemUIOverlayStyle(
                    SystemUiOverlayStyle.dark);
              } else {
                SystemChrome.setEnabledSystemUIOverlays([]);
              }
            }
          }
        })
      ],
      builder: (c, w) {
        ScreenUtil.instance =
            ScreenUtil(width: 750, height: 1334, allowFontScaling: true)
              ..init(c);
        var data = MediaQuery.of(c);
        return MediaQuery(
          data: data.copyWith(textScaleFactor: 1.0),
          child: w,
        );
      },
      initialRoute: Routes.FLUTTERCANDIES_MAINPAGE,// fluttercandies://mainpage
      onGenerateRoute: (RouteSettings settings) =>
          onGenerateRouteHelper(settings, notFoundFallback: NoRoute()),
    ),
  );
}

More info

Push #

Push name #

  Navigator.pushNamed(context, Routes.FLUTTERCANDIES_MAINPAGE /* fluttercandies://mainpage */);

Push name with arguments #

arguments MUST be a Map<String, dynamic>

  Navigator.pushNamed(
    context,
    Routes.FLUTTERCANDIES_PICSWIPER, // fluttercandies://picswiper
    arguments: {
      "index": index,
      "pics": listSourceRepository
          .map<PicSwiperItem>((f) => PicSwiperItem(f.imageUrl, des: f.title))
          .toList(),
    },
  );

2.0.3 #

  • Breaking change Route instead of RouteSetting for RouteChange call back.
  • Demo Track page only for PageRoute

2.0.2 #

  • Fix error about -na, --no-arguments.

2.0.1 #

  • Add more friendly prompt.

2.0.0 #

  • Breaking change

Manage your Flutter app development with ff_annotation_route.

Activate: pub global activate ff_annotation_route

Usage: ff_route <command> [arguments]

Available commands:

-h , --help                         Print this usage information.

-p , --path [arguments]    The path of folder to be executed with commands.

-rc, --route-constants       Whether generate route names as constants.

-rh, --route-helper            Whether generate xxx_route_helper.dart

-rn, --route-names            Whether generate route names as a list.

-s , --save                          Whether save commands in local, it will read commands from local next time to execute if run "ff_route" without any commands.

-na, --no-arguments         Whether RouteSettings has arguments(for lower flutter sdk).

1.1.9 #

  • Merge files from 1.1.8.

1.1.8 #

  • Fix NPE when _didRouteChange was called.
  • Update onGenerateRouteHelper's not found fallback.

1.1.7 #

  • Fix route constants didn't generated for submodules.
  • Generated routes will be sorted.
  • Update parameter for onGenerateRouteHelper.
  • Remove showStatusBarChange from FFNavigatorObserver.
  • Improve code quality and remove redundant code.

1.1.6 #

  • Add onGenerateRouteHelper to helper file instead of written in MaterialApp.

1.1.5 #

  • Add const private constructor.

1.1.4 #

  • Fix format failed.
  • Fix demo error.

1.1.3+2 #

  • Remove _ while route constant was start with /, which will cause the constant unreachable.

1.1.3+1 #

  • Remove the deprecated author: field from pubspec.yaml
  • Update codes according to health suggestion.

1.1.3 #

  • Add generateRouteConstants param to generate routes in Routes with constants.

1.1.2 #

  • Format output files.

1.1.1 #

  • Correct typos and formatted codes

1.1.0 #

  • Fix null exception about dependencies

1.0.9 #

  • Fix demo issue and update analyzer version

1.0.7 #

  • Add description parameter for FFRoute

1.0.6 #

  • Command "checkEnable" is obsolete now. only sacn the project/package which has dependency of "ff_annotation_route"

1.0.5 #

  • Fix FFNavigatorObserver

1.0.4 #

  • Public getFFRouteSettings

1.0.3 #

  • Fix getRouteResult method error

1.0.2 #

  • Correct analyzer version for flutter low sdk

1.0.1 #

  • Correct analyzer version

1.0.0 #

  • First Version

example/README.md

example #

A new Flutter project.

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 an executable

1. Install it

You can install the package from the command line:


$ pub global activate ff_annotation_route

2. Use it

The package has the following executables:


$ ff_route

Use this package as a library

1. Depend on it

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


dependencies:
  ff_annotation_route: ^2.0.3

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

Alternatively, your editor might support pub get or 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:ff_annotation_route/ff_annotation_route.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
69
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]
85
Learn more about scoring.

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

  • Dart: 2.7.1
  • pana: 0.13.5

Health suggestions

Format lib/src/command/route_names.dart.

Run dartfmt to format lib/src/command/route_names.dart.

Format lib/src/command/save.dart.

Run dartfmt to format lib/src/command/save.dart.

Format lib/src/command/settings_no_arguments.dart.

Run dartfmt to format lib/src/command/settings_no_arguments.dart.

Format lib/src/utils.dart.

Run dartfmt to format lib/src/utils.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.2.0 <3.0.0
analyzer ^0.39.2+1 0.39.4
io ^0.3.3 0.3.3
meta ^1.1.8 1.1.8
path ^1.0.0 1.6.4
yaml ^2.0.0 2.2.0
Transitive dependencies
_fe_analyzer_shared 1.0.3
args 1.5.2
async 2.4.0
charcode 1.1.3
collection 1.14.12
convert 2.1.1
crypto 2.1.4
csslib 0.16.1
glob 1.2.0
html 0.14.0+3
js 0.6.1+1
node_interop 1.0.3
node_io 1.0.1+2
package_config 1.1.0
pedantic 1.9.0
pub_semver 1.4.3
source_span 1.6.0
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.1.6
watcher 0.9.7+13