Skip to content

Commit

Permalink
🚧 (UnmaskedHeroController) Extends NavigatorObserver to listen
Browse files Browse the repository at this point in the history
to navigation behaviors, such as: "didPush"
  • Loading branch information
guitoof committed May 30, 2021
1 parent 065bd9d commit b18b384
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/main.dart
@@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'package:hero_animation_unmasked/pages/hero_details_page.dart';
import 'package:hero_animation_unmasked/pages/hero_list_page.dart';
import 'package:hero_animation_unmasked/packages/unmasked_hero/unmasked_hero_controller.dart';

void main() {
runApp(MyApp());
Expand All @@ -11,6 +12,7 @@ class MyApp extends StatelessWidget {
Widget build(BuildContext context) {
return MaterialApp(
initialRoute: 'hero_list_page',
navigatorObservers: [UnmaskedHeroController()],
routes: {
'hero_list_page': (context) => HeroListPage(),
'hero_details_page': (context) => HeroDetailsPage(),
Expand Down
9 changes: 9 additions & 0 deletions lib/packages/unmasked_hero/unmasked_hero_controller.dart
@@ -0,0 +1,9 @@
import 'package:flutter/widgets.dart';

class UnmaskedHeroController extends NavigatorObserver {
@override
void didPush(Route<dynamic> route, Route<dynamic>? previousRoute) {
print('Navigating from $previousRoute to $route');
super.didPush(route, previousRoute);
}
}

0 comments on commit b18b384

Please sign in to comment.