route_observer_mixin 1.0.0 copy "route_observer_mixin: ^1.0.0" to clipboard
route_observer_mixin: ^1.0.0 copied to clipboard

outdated

RouteObserveMixin provides easy access to didPush/didPop/didPushNext/didPopNext.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:route_observer_mixin/route_observer_mixin.dart';

import 'log_view.dart';
import 'pages/pages.dart';

void main() {
  runApp(
    MultiProvider(
      providers: [
        // 1. Wrap MaterialApp with RouteObserverProvider.
        RouteObserverProvider(),
        ChangeNotifierProvider(builder: (context) => Logger())
      ],
      child: const App(),
    ),
  );

  // Of course, this is also ok.
  // I demonstrated that [MultiProvider] can be used for RouteObserverProvider👍

  /*
  runApp(
    RouteObserverProvider(
      child: const App(),
    ),
  );
  */
}

class App extends StatelessWidget {
  const App({Key key}) : super(key: key);
  @override
  Widget build(BuildContext context) {
    return Column(
      children: [
        Expanded(
          child: MaterialApp(
            // 2. Pass RouteObserverProvider.of(context) to navigatorObservers.
            navigatorObservers: [RouteObserverProvider.of(context)],
            home: const APage(),
          ),
        ),
        const LogView(),
      ],
    );
  }
}
20
likes
0
pub points
87%
popularity

Publisher

verified publishermono0926.com

RouteObserveMixin provides easy access to didPush/didPop/didPushNext/didPopNext.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter, provider

More

Packages that depend on route_observer_mixin