ok_route 0.1.4

  • Readme
  • Changelog
  • Installing
  • 46

ok_route #

Annotation route of flutter.

Usage #

import project #

dependencies:
  ok_route_library: ^0.1.1

Add Annotation to your widget #

import 'package:ok_route_library/ok_route_library.dart';

@OKRoute("/home")
class HomePage extends StatelessWidget{
    // ...
}

Generate route class #

How to use pub global #

Use pub global

Add pub/pub.bat to your $PATH.

Add cache/bin to your path like image

20190808104703.png

Get generator #

$ pub global activate ok_route

or

$ pub.bat global activate ok_route

Use generator #

$ ok_route $your_project

Use route in your project #

import 'package:ok_route_example/okroutes.dart'; // The dart file have the routes.

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(title: 'Flutter Demo Home Page'),
      onGenerateRoute: OKRouteMap.onGenerateRoute, // routes create by ok_route.
    );
  }
}

Pass params #

Push #

Only support basic type, because it will be converted to json during the transfer process.

import 'package:ok_route_library/ok_route_library.dart';

  final name = OKRoute.createPushString(
    "/sub_home",
    params: {"name": "hello"},
  );
  Navigator.of(context).pushNamed(name);

// or

  OKRoute.pushNamed(context, "/sub_home", params: {"name": "hello"},);

Get #

import 'package:ok_route_library/ok_route_library.dart';

@OKRoute("/sub_home")
class Page extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    final name = OKRoute.getParams(context)["name"]; // Get params , the params type is Map<String,dynamic>.
    return Scaffold(
      appBar: AppBar(
        title: Text("title"),
      ),
      body: Container(
        child: Column(
          children: <Widget>[
            Text(name),
          ],
        ),
      ),
    );
  }
}

LICENSE #

MIT style

0.1.3 #

  • The library is tools.
  • Split a flutter library for flutter.

0.1.2 #

Fix bug.

Support pass param.

0.1.1 #

Update project structure.

0.1.0 #

  • Initial version, created by Caijinglong

Use this package as an executable

1. Install it

You can install the package from the command line:


$ pub global activate ok_route

2. Use it

The package has the following executables:


$ ok_route

Use this package as a library

1. Depend on it

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


dependencies:
  ok_route: ^0.1.4

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

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

  • Dart: 2.5.1
  • pana: 0.12.21

Platforms

Detected platforms: Flutter, web, other

No platform restriction found in primary library package:ok_route/ok_route.dart.

Health issues and suggestions

Document public APIs. (-1 points)

44 out of 44 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.

Fix bin/main.dart. (-1 points)

Analysis of bin/main.dart reported 2 hints:

line 3 col 8: Unused import: 'package:ok_route/ok_route.dart'.

line 8 col 7: Use isEmpty instead of length

Fix lib/src/code_maker.dart. (-0.50 points)

Analysis of lib/src/code_maker.dart reported 1 hint:

line 3 col 8: Unused import: 'package:ok_route/ok_route.dart'.

Format lib/generator.dart.

Run dartfmt to format lib/generator.dart.

Maintenance suggestions

Maintain an example. (-10 points)

Create a short demo in the example/ directory to show how to use this package.

Common filename patterns include main.dart, example.dart, and ok_route.dart. Packages with multiple examples should provide example/README.md.

For more information see the pub package layout conventions.

The package description is too short. (-5 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
yaml ^2.1.16 2.2.0
Transitive dependencies
charcode 1.1.2
collection 1.14.12
meta 1.1.7
path 1.6.4
source_span 1.5.5
string_scanner 1.0.5
term_glyph 1.1.0
Dev dependencies
test ^1.0.0