veno_router 0.0.2 copy "veno_router: ^0.0.2" to clipboard
veno_router: ^0.0.2 copied to clipboard

outdated

Flutter plugin.

veno_router #

Flutter 路由

  • 嵌套视图
  • 路径参数
  • query string

例子 #

import 'package:flutter/material.dart';
import 'package:veno_router/veno_router.dart';

class ParentView extends StatelessWidget {
  Widget child;

  ParentView({Key key, this.child}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: Wrap(
          children: [
            Text('公共'),
            child ??
                OutlineButton(
                  onPressed: () =>
                      Navigator.of(context).pushNamed('/products/1'),
                  child: Text('子页面'),
                ),
          ],
        ),
      ),
    );
  }
}

class ChildView extends StatelessWidget {
  VenoRoute route;

  ChildView({Key key, this.route}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return OutlineButton(
      onPressed: () => Navigator.of(context).pop(),
      child: Text('${route.params} 返回父页面'),
    );
  }
}

class App extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      onGenerateRoute: VenoRouter(routes: [
        VenoRoute(
          path: '/',
          builder: (child, __) => ParentView(child: child),
          children: [
            VenoRoute(
              path: '/products/:id',
              builder: (_, VenoRoute route) => ChildView(route: route),
            ),
          ],
        ),
      ]).buildPageRouteFactory(),
    );
  }
}

void main() {
  runApp(App());
}
0
likes
0
pub points
0%
popularity

Publisher

unverified uploader

Flutter plugin.

Homepage
Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter

More

Packages that depend on veno_router