navigation_manager 1.1.0 copy "navigation_manager: ^1.1.0" to clipboard
navigation_manager: ^1.1.0 copied to clipboard

discontinuedreplaced by: get
outdated

Navigation manager for Navigator 2.0 with a convenient declarative way to define application routes.

Navigation plugin #

Features #

  • ✅ Navigator 2.0 support
  • ✅ Duplicate strategies and tree concept
  • ✅ Uri templates parsing. Check uri package and RFC 6570
  • ✅ Global / per route transitions
  • 🛠️ Nested sub-trees

Good to read #

  • You could read sub-tree concept doc for better understand duplicate strategies.

Minimal Installation #

Define routes

// routes.dart

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

abstract class Routes {
  static final main = AppRoute.subroot(
    '/',
    (Map<String, dynamic> data) => const YourPageWidget(),
    duplicateStrategy: SubRootDuplicateStrategy.MakeVisible, // optional, default value
  );

  static final unknown = AppRoute(
    '/404',
    (data) => YourUnkwownRoutePage(),
    duplicateStrategy: DuplicateStrategy.Ignore // optional, default value
  );

  static final appRoutes = [
    main,
  ];
}

Setup navigator

// main.dart

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

void main() {
  runApp(MyApp());
}

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  late final RouteManager routeManager;

  @override
  void initState() {
    routeManager = RouteManager(
      initialRoute: Routes.main, // required
    );
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp.router(
      routerDelegate: AppRouteDelegate(
        routeManager: routeManager, // required
      ),
      routeInformationParser: AppRouteInformationParser(
        unknownRoute: Routes.unknown, // required 
        routes: Routes.appRoutes, // required
      ),
    );
  }
}

And use them

routeManager.push(AppRoute, {Map<String, dynamic> data})
routeManager.pop()

/// Removes the specified route from the routes list.
/// If the specified route is sub-root then entire sub-tree will be deleted.
routeManager.remove(AppRoute)

/// Removes all routes from the routes list after the specified.
routeManager.removeUntil(AppRoute)
2
likes
0
pub points
34%
popularity

Publisher

verified publisherdart.nogipx.ru

Navigation manager for Navigator 2.0 with a convenient declarative way to define application routes.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

equatable, flutter, meta, uri

More

Packages that depend on navigation_manager