annotation_route 0.0.2

  • README.md
  • CHANGELOG.md
  • Installing
  • Versions
  • new35

annotation_route

Description

a router config mapping solution based on source_gen through annotation

Usage

  1. Notice: your page should own a constuctor that can be initialized with unique param, then Annotate the page class with @ARoute
    example:

    @ARoute(url: 'myapp://pagea')
    class A {
     A(MyRouteOption option): super();
    }
    
  2. Annotate your own router class with @ARouteRoot
    example:

    @ARouteRoot()
    class MyRouter {}
    
  3. run the build_annotation_route.sh in your workspace Or just run the command below in your workspace
    build:

     flutter packages pub run build_runner build --delete-conflicting-outputs
    

    suggest you running the clean command before build:
    clean:

     flutter packages pub run build_runner clean
    
  4. now you can get the instance
    example:

    @ARouteRoot()
    class Router {
     ARouterInternal internal = ARouterInternalImpl();
     dynamic getPage(MyRouteOption option) {
       return internal.findPage(
           ARouteOption(option.urlpattern, option.params), option);
     }
    }
    
    class MyRouteOption {
     String urlpattern;
     Map<String, dynamic> params;
    }
    
  5. examples placed in 'lib/example/*'

Installation

install from packages

add packages to dev_dependencies in your pubspec.yaml
example:

dev_dependencies:
  annotation_route: any

install from source code

clone the code, then put it into your workspace, announce it in your pubspec.yaml exxample:

dev_dependencies:
  annotation_route:
    path: annotation_route

简介

一个以注解方式实现的路由映射解决方案,基于 source_gen

使用

  1. 注意: 你的页面应该实现指定的构造器,一个接受唯一参数的构造器,然后使用@ARoute 注解你的页面类
    例:

    @ARoute(url: 'myapp://pagea')
    class A {
     A(MyRouteOption option): super();
    }
    
  2. 使用 @ARouteRoot 注解 你自己的 router 类 例:

    @ARouteRoot()
    class MyRouter {}
    
  3. 在你的工作目录下运行 build_annotation_route.sh 脚本,或者运行如下命令:
    build:

     flutter packages pub run build_runner build --delete-conflicting-outputs
    

    建议在执行 build 命令前,先执行如下命令:
    clean:

     flutter packages pub run build_runner clean
    
  4. 现在你可以使用它来获取类的实例了
    例:

    @ARouteRoot()
    class Router {
     ARouterInternal internal = ARouterInternalImpl();
     dynamic getPage(MyRouteOption option) {
       return internal.findPage(
           ARouteOption(option.urlpattern, option.params), option);
     }
    }
    
    class MyRouteOption {
     String urlpattern;
     Map<String, dynamic> params;
    }
    
  5. 具体代码可以参考 lib/example/*下的文件

安装

从 pub 安装

在你的 pubspec.yaml 文件下声明
例:

dev_dependencies:
  annotation_route: any

从源码安装

拷贝代码至你的工作目录,在你的 pubspec.yaml 文件下声明
例:

dev_dependencies:
  annotation_route:
    path: annotation_route

0.0.1

  • Ready for experimentation.

0.0.1+1

  • Format code by lint rules.

Use this package as a library

1. Depend on it

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


dependencies:
  annotation_route: ^0.0.2

2. Install it

You can install packages from the command line:

with pub:


$ pub get

Alternatively, your editor might support pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:annotation_route/builder.dart';
import 'package:annotation_route/example/page_a.dart';
import 'package:annotation_route/example/page_b.dart';
import 'package:annotation_route/example/page_c.dart';
import 'package:annotation_route/example/page_d.dart';
import 'package:annotation_route/example/router.route.dart';
import 'package:annotation_route/example/router.route.internal.dart';
import 'package:annotation_route/route.dart';
  
Version Uploaded Documentation Archive
0.0.2 Nov 23, 2018 Go to the documentation of annotation_route 0.0.2 Download annotation_route 0.0.2 archive
0.0.1+1 Nov 19, 2018 Go to the documentation of annotation_route 0.0.1+1 Download annotation_route 0.0.1+1 archive
0.0.1 Nov 19, 2018 Go to the documentation of annotation_route 0.0.1 Download annotation_route 0.0.1 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
15
Health:
Code health derived from static analysis. [more]
65
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
40
Overall:
Weighted score of the above. [more]
35
Learn more about scoring.

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

  • Dart: 2.1.0
  • pana: 0.12.7

Platforms

Detected platforms: other

Platform components identified in package: build, io, mirrors.

Health issues and suggestions

Fix lib/example/router.route.dart. (-25 points)

Analysis of lib/example/router.route.dart failed with 1 error:

line 6 col 3: The name 'ARouterInternal' is defined in the libraries 'package:annotation_route/example/router.route.internal.dart' and 'package:annotation_route/route.dart'.

Document public APIs (-10 points)

80 out of 80 API elements (library, class, field or method) have no adequate dartdoc content. Good documentation improves code readability and discoverability through search.

Maintenance issues and suggestions

Use constrained dependencies. (-20 points)

The pubspec.yaml contains 5 dependencies without version constraints. Specify version ranges for the following dependencies: analyzer, build, build_config, mustache4dart, source_gen.

The description is too short. (-20 points)

Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.

Maintain an example. (-10 points)

Create a short demo in the example/ directory to show how to use this package. Common file name patterns include: main.dart, example.dart or you could also use annotation_route.dart.

Package is pre-v0.1 release. (-10 points)

While there is nothing inherently wrong with versions of 0.0.*, it usually means that the author is still experimenting with the general direction of the API.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0
analyzer any 0.33.6 0.34.0
build any 1.0.1
build_config >=0.3.0 0.3.1+4
mustache4dart any 3.0.0-dev.1.0
source_gen >=0.8.0 0.9.1+3
Transitive dependencies
args 1.5.1
async 2.0.8
build_resolvers 0.2.2+6
build_runner_core 1.1.1
built_collection 4.1.0
built_value 6.1.6
charcode 1.1.2
code_builder 3.1.3
collection 1.14.11
convert 2.0.2
crypto 2.0.6
csslib 0.14.6
dart_style 1.2.0 1.2.1
fixnum 0.10.9
front_end 0.1.6+8 0.1.7
glob 1.1.7
graphs 0.1.3+1
html 0.13.3+3
http 0.12.0
http_multi_server 2.0.5
http_parser 3.1.3
io 0.3.3
js 0.6.1+1
json_annotation 2.0.0
kernel 0.3.6+8 0.3.7
logging 0.11.3+2
matcher 0.12.4
meta 1.1.6
mime 0.9.6+2
package_config 1.0.5
package_resolver 1.0.6
path 1.6.2
pedantic 1.3.0
plugin 0.2.0+3
pool 1.3.6
pub_semver 1.4.2
pubspec_parse 0.1.2+3
quiver 2.0.1
reflectable 2.0.8
shelf 0.7.3+3
shelf_web_socket 0.2.2+4
source_span 1.4.1
stack_trace 1.9.3
stream_channel 1.6.8
stream_transform 0.0.14+1
string_scanner 1.0.4
timing 0.1.1+1
typed_data 1.1.6
utf 0.9.0+5
watcher 0.9.7+10
web_socket_channel 1.0.9
yaml 2.1.15
Dev dependencies
build_runner >=0.9.1 1.1.2
test any