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,
  ],

Constructors

AppRouteObserver()
factory

Properties

hashCode int
The hash code for this object.
no setterinherited
routeObserver RouteObserver<ModalRoute<void>>
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited