router_management 3.1.0 copy "router_management: ^3.1.0" to clipboard
router_management: ^3.1.0 copied to clipboard

A plugin that wraps the Navigator 2.0 with a syntax sugar for Flutter Developers

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:router_management/router_management.dart';

import 'ui/home_screen.dart';
import 'ui/not_found.dart';
import 'ui/profile_screen.dart';
import 'ui/splash_screen.dart';

void main() {
  runApp(
    NavigationRouter(
      child: App(), // The NavigationWidgetMixin that builds a Router
      pages: [
        NavigationPage(
          path: SplashScreen.path,
          builder: () => const SplashScreen(),
          name: SplashScreen.name,
        ),
        NavigationPage(
          path: HomeScreen.path,
          builder: () => const HomeScreen(),
          name: HomeScreen.name,
        ),
        NavigationPage(
          path: ProfileScreen.path,
          builder: () => NavigationRouterGuard(
            child: const ProfileScreen(),
            validation: (args) async {
              if (args.query['name'] == null) return false;

              return true;
            },
          ),
          name: ProfileScreen.name,
        ),
      ], // The pages
      // The initial page's path. Defaults to "/"
      initialPage: SplashScreen.path,
      unknownPage: NavigationPage(
        path: NotFound.path,
        builder: () => const NotFound(),
        name: NotFound.name,
      ), // A page that is built when an unknown path is passed
    ),
  );
}

class App extends StatelessWidget with NavigationWidgetMixin {
  App({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp.router(
      routeInformationParser: routeInformationParser,
      routerDelegate: routerDelegate,
      title: 'Router Management Example',
      localizationsDelegates: GlobalMaterialLocalizations.delegates,
    );
  }
}

// or

// class App extends StatefulWidget with NavigationWidgetMixin {
//   App({Key? key}) : super(key: key);
//
//   @override
//   _AppState createState() => _AppState();
// }
//
// class _AppState extends State<App> {
//   @override
//   Widget build(BuildContext context) {
//     return MaterialApp.router(
//       routeInformationParser: widget.routeInformationParser,
//       routerDelegate: widget.routerDelegate,
//       title: 'Router Management Example',
//       localizationsDelegates: GlobalMaterialLocalizations.delegates,
//     );
//   }
// }
9
likes
130
pub points
57%
popularity

Publisher

verified publishervegasdevelopments.com

A plugin that wraps the Navigator 2.0 with a syntax sugar for Flutter Developers

Homepage
Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter, url_strategy

More

Packages that depend on router_management