didPushRoute method

  1. @override
  2. @protected
  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

@override
@protected
@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

  // Don't if the State object is defunct.
  if (!mounted) {
    return true;
  }

  /// 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 con in controllerList) {
    final didPush = await con.didPushRoute(route);
    if (didPush) {
      handled = true;
    }
  }

  _setStateAllowed = true;

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

  return handled;
}