navigation_saver 0.3.3 copy "navigation_saver: ^0.3.3" to clipboard
navigation_saver: ^0.3.3 copied to clipboard

This library will help to restore navigation stack after application kill.

example/lib/main.dart

import 'package:example/home/home_page.dart';
import 'package:example/home/home_page_arguments.dart';
import 'package:flutter/material.dart';
import 'package:navigation_saver/navigation_saver.dart';

void main() {
  Iterable<RouteSettings> savedRoutes = <RouteSettings>[];
  final NavigationSaver _navigatorSaver = NavigationSaver(
    (Iterable<RouteSettings> routes) async {
      return savedRoutes = routes;
    },
    () async => savedRoutes,
  );

  runApp(MyApp(_navigatorSaver));
}

class MyApp extends StatelessWidget {
  MyApp(this._navigationSaver);

  final NavigationSaver _navigationSaver;

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      initialRoute: NavigationSaver.restoreRouteName,
      onGenerateRoute: (RouteSettings routeSettings) =>
          _navigationSaver.onGenerateRoute(
              routeSettings,
              (
                RouteSettings settings, {
                NextPageInfo nextPageInfo,
              }) =>
                  MaterialPageRoute(
                    builder: (BuildContext context) => MyHomePage(
                      initialCounter: settings.arguments is MyHomePageArguments
                          ? (settings.arguments as MyHomePageArguments)
                              .deepIndex
                          : 0,
                      nextPageInfo: nextPageInfo,
                    ),
                    settings: routeSettings,
                  )),
      navigatorObservers: [_navigationSaver],
    );
  }
}
5
likes
40
points
30
downloads

Publisher

verified publisherscal.io

Weekly Downloads

This library will help to restore navigation stack after application kill.

Homepage
Repository (GitHub)
View/report issues

Documentation

Documentation

License

BSD-3-Clause (license)

Dependencies

flutter, pedantic

More

Packages that depend on navigation_saver