route_tree 1.0.0-nullsafety.1
route_tree: ^1.0.0-nullsafety.1 copied to clipboard

RouteTree is a generic routing library that makes it easy to implement routing logic based on the path segments of a URI.

example/main.dart

import 'package:route_tree/route_tree.dart';

void main() {
  final router = Segment.root<String>(
    create: (context) => 'home',
    createError: (context) => 'Error!',
    children: [
      Segment.path(
        name: 'first_path',
        create: (context) => 'routed to first_path',
      ),
      Segment.path(
        name: 'second_path',
        create: (context) => 'routed to second_path',
        children: [
          Segment.param(
            parser: const UintParser('id'),
            create: (context) => 'routed to /second_path/${context['id']}',
          ),
        ],
      ),
    ],
  );

  assert(
      router.route(Uri.parse('/second_path/12')) == 'routed to second_path/12');
}
1
likes
130
pub points
0%
popularity

RouteTree is a generic routing library that makes it easy to implement routing logic based on the path segments of a URI.

Homepage
Repository (GitLab)
View/report issues

Documentation

API reference

Uploader

shewebi@gmail.com

License

BSD (LICENSE)

Dependencies

result_class

More

Packages that depend on route_tree