ok_route 0.1.4 copy "ok_route: ^0.1.4" to clipboard
ok_route: ^0.1.4 copied to clipboard

discontinued

Use route with annotation. See document for how to use.

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
likes
20
pub points
0%
popularity

Publisher

unverified uploader

Use route with annotation. See document for how to use.

Repository (GitHub)
View/report issues

License

MIT (LICENSE)

Dependencies

yaml

More

Packages that depend on ok_route