flutter_web_router 0.0.1+2
flutter_web_router: ^0.0.1+2

Flutter Android iOS web

A router that handles request URIs with wildcards and generate URIs with parameters.

flutter_web_router #

A router that handles request URIs with wildcards and generate URIs with parameters.

usage #

  1. Set up WebRouter
    final router = WebRouter();

If you want to show error pages, please add error pages.

    router.addForbiddenRoute((request) => ForbiddenPage());
    router.addNotFoundRoute((request) => NotFoundPage());
    router.addInternalErrorRoute((request) => InternalErrorPage());

Please add URIs of page. You can add URIs with wildcards.

    router.addRoute('/login', (request) => LoginPage());
    router.addRoute('/', (request) => DashboardPage());
    router.addRoute('items/index', (request) => ItemListPage());
    router.addRoute('items/view/{itemId}', (request) => ItemViewPage(request: request));

If you want to verify a user, please add filters.

LoginVerificationFilter is a sample class that implements WebFilter class.

    router.addFilter(LoginVerificationFilter());

Finally, you can set a transition.

    // set OnComplete handler
    router.setOnComplete((settings, widget) {
      // fade transition
      return PageRouteBuilder(
        settings: settings,
        pageBuilder: (_, __, ___) => widget,
        transitionsBuilder: (_, anim, __, child) {
          return FadeTransition(
            opacity: anim,
            child: child,
          );
        },
      );
    });
  1. set router.build() to onGenerateRoute
    return MaterialApp(
      ...
      onGenerateRoute: router.build(),
      ...
    );
  1. navigate with WebRequest

If you want to request URIs used wildcards, use WebRequest.

    final request = WebRequest.request(
      'items/view/{itemId}',
      data: {
        'itemId': '1',
      },
    );
    await Navigator.of(context).pushNamed(
      request.uri.toString(),
    );
3
likes
110
pub points
25%
popularity

Publisher

keyber.jp

A router that handles request URIs with wildcards and generate URIs with parameters.

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD (LICENSE)

Dependencies

flutter

More

Packages that depend on flutter_web_router