go_router 0.9.0 copy "go_router: ^0.9.0" to clipboard
go_router: ^0.9.0 copied to clipboard

outdated

A declarative router for Flutter based on Navigation 2 supporting deep linking, data-driven routes and more

example/lib/main.dart

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

import 'shared/pages.dart';

void main() => runApp(App());

/// sample class using simple declarative routes
class App extends StatelessWidget {
  App({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) => MaterialApp.router(
        routeInformationParser: _router.routeInformationParser,
        routerDelegate: _router.routerDelegate,
        title: 'Declarative Routes GoRouter Example',
      );

  final _router = GoRouter(
    routes: [
      GoRoute(
        path: '/',
        builder: (context, state) => MaterialPage<void>(
          key: state.pageKey,
          child: const Page1Page(),
        ),
      ),
      GoRoute(
        path: '/page2',
        builder: (context, state) => MaterialPage<void>(
          key: state.pageKey,
          child: const Page2Page(),
        ),
      ),
    ],

    error: (context, state) => MaterialPage<void>(
      key: state.pageKey,
      child: ErrorPage(state.error),
    ),
  );
}
4.96k
likes
0
points
1.33M
downloads

Publisher

verified publisherflutter.dev

Weekly Downloads

A declarative router for Flutter based on Navigation 2 supporting deep linking, data-driven routes and more

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

collection, flutter, flutter_web_plugins, path_to_regexp

More

Packages that depend on go_router