subscribeState method

bool subscribeState(
  1. RouteAware? object
)

Make a State object aware of route changes.

Implementation

bool subscribeState(RouteAware? object) {
  //
  var sub = object != null;

  /// DO NOT USE ModalRoute.of()
  ///  I don't want to rebuilt the State objects with every Navigator change
//    route ??= ModalRoute.of(state.context); // InheritedWidget?!

  Route<dynamic>? route;

  if (sub) {
    route = currentRoute;
    sub = route != null;
  }

  if (sub) {
    // So to be informed when there are changes to route.
    subscribe(object!, route!);
  }
  return sub;
}