ff_annotation_route 1.1.2

  • Readme
  • Changelog
  • Example
  • Installing
  • 82

ff_annotation_route #

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

Language: English | 中文简体

Description #

Provide route generator to create route map quickly by annotations.

Usage #

Add packages to dev_dependencies #

add packages to dev_dependencies in your project/packages's pubspec.yaml

dev_dependencies:
  ff_annotation_route: any

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
argumentNamesThe argument names passed to FFRoute.-
showStatusBarWhether show status bar.true
routeNameThe route name to track page''
pageRouteTypeThe type of page route(material, cupertino, transparent)-
descriptionThe description of route''

Generate Route File #

Environment #

add dart bin into to your $PATH.

cache\dart-sdk\bin

more info

Activate #

pub global activate ff_annotation_route

Execute command #

you can cd to your project and execute command. ff_annotation_route

or you can execute command with your project path ff_annotation_route path=

Command Parameter #

use as parameter=xxx, and use space to split them.

parameterdescriptiondefault
pathThe path of your project.current
generateRouteNamesWhether generate route names in xxx_route.dart at root projectfalse
mode0 or 1, 1 will generate xxx_route_helper.dart to help you to handle showStatusBar/routeName/pageRouteType0
routeSettingsNoArgumentsif true, FFRouteSettings(in xxx_route_helper.dart) has no arguments for low flutter sdkfalse

Main.dart #

  • if you execute command with mode=1, FFNavigatorObserver/FFRouteSettings will generate in xxx_route_helper.dart they help you to track page or change status bar state.

  • if you execute command with mode=1, FFTransparentPageRoute will generate in xxx_route_helper.dart it 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: (name) {
          //you can track page here
          print(name);
        }, showStatusBarChange: (bool showStatusBar) {
          if (showStatusBar) {
            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: "fluttercandies://mainpage",
      onGenerateRoute: (RouteSettings settings) {
        var routeResult =
            getRouteResult(name: settings.name, arguments: settings.arguments);

        if (routeResult.showStatusBar != null ||
            routeResult.routeName != null) {
          settings = FFRouteSettings(
              arguments: settings.arguments,
              name: settings.name,
              isInitialRoute: settings.isInitialRoute,
              routeName: routeResult.routeName,
              showStatusBar: routeResult.showStatusBar);
        }

        var page = routeResult.widget ?? NoRoute();

        switch (routeResult.pageRouteType) {
          case PageRouteType.material:
            return MaterialPageRoute(settings: settings, builder: (c) => page);
          case PageRouteType.cupertino:
            return CupertinoPageRoute(settings: settings, builder: (c) => page);
          case PageRouteType.transparent:
            return FFTransparentPageRoute(
                settings: settings,
                pageBuilder: (BuildContext context, Animation<double> animation,
                        Animation<double> secondaryAnimation) =>
                    page);
          default:
            return Platform.isIOS
                ? CupertinoPageRoute(settings: settings, builder: (c) => page)
                : MaterialPageRoute(settings: settings, builder: (c) => page);
        }
      },
    ));
  }

more info

Push #

Push name #

  Navigator.pushNamed(context, "fluttercandies://mainpage");

Push name with arguments #

and arguments should be Map<String,dynamic>

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

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_annotation_route

Use this package as a library

1. Depend on it

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


dependencies:
  ff_annotation_route: ^1.1.2

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]
68
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
90
Overall:
Weighted score of the above. [more]
82
Learn more about scoring.

We analyzed this package on Dec 10, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.0
  • pana: 0.13.1+4

Health suggestions

Fix lib/ff_annotation_route.dart. (-0.50 points)

Analysis of lib/ff_annotation_route.dart reported 1 hint:

line 5 col 8: Unused import: 'dart:io'.

Format lib/src/package_graph.dart.

Run dartfmt to format lib/src/package_graph.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 (analyzer).

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
analyzer ^0.38.3 0.38.5 0.39.2+1
path ^1.0.0 1.6.4
yaml ^2.0.0 2.2.0
Transitive dependencies
args 1.5.2
async 2.4.0
charcode 1.1.2
collection 1.14.12
convert 2.1.1
crypto 2.1.4
csslib 0.16.1
front_end 0.1.27 0.1.29
glob 1.2.0
html 0.14.0+3
js 0.6.1+1
kernel 0.3.27 0.3.29
meta 1.1.8
node_interop 1.0.3
node_io 1.0.1+2
package_config 1.1.0
pedantic 1.9.0
pub_semver 1.4.2
source_span 1.5.5
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.1.6
watcher 0.9.7+13