AppRouteObserver class
class ObserverPage extend State<> with RouteAware {
@override
void didChangeDependencies() {
super.didChangeDependencies();
// 注册监听
AppRouteObserver().routeObserver.subscribe(this, ModalRoute.of(context));
}
void dispose() {
// 注销监听
AppRouteObserver().routeObserver.unsubscribe(this);
super.dispose();
}
@override
void didPop() {
}
}
### main.dart
navigatorObservers: [
AppRouteObserver().routeObserver,
],
Methods
-
noSuchMethod(Invocation invocation)
→ dynamic
-
Invoked when a nonexistent method or property is accessed.
inherited
-
toString()
→ String
-
A string representation of this object.
inherited