didPushRoute method

  1. @protected
  2. @override
  3. @mustCallSuper
Future<bool> didPushRoute(
  1. String route
)
inherited

Called when the host tells the app to push a new route onto the navigator.

Implementation

@protected
@override
@mustCallSuper
Future<bool> didPushRoute(String route) async {
  /// Observers are expected to return true if they were able to
  /// handle the notification. Observers are notified in registration
  /// order until one returns true.
  ///
  /// This method exposes the `pushRoute` notification from

  /// No 'setState()' functions are allowed to fully function at this point.
  _setStateAllowed = false;

  /// Set if a StateXController successfully 'handles' the notification.
  bool handled = false;

  for (final listener in _beforeList) {
    await listener.didPushRoute(route);
  }
  for (final con in _controllerList) {
    final didPush = await con.didPushRoute(route);
    if (didPush) {
      handled = true;
    }
  }
  for (final listener in _afterList) {
    await listener.didPushRoute(route);
  }

  _setStateAllowed = true;

  if (_setStateRequested) {
    _setStateRequested = false;
    // Only the latest State is rebuilt
    if (isEndState) {
      /// Perform a 'rebuild' if requested.
      setState(() {});
    }
  }

  return handled;
}