didPushRouteInformation method

  1. @override
  2. @protected
  3. @mustCallSuper
Future<bool> didPushRouteInformation(
  1. RouteInformation routeInformation
)
inherited

Called when the host tells the application to push a new RouteInformation and a restoration state onto the router.

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 pushRouteInformation notification from SystemChannels.navigation.

The default implementation is to call the didPushRoute directly with the RouteInformation.uri.

Implementation

// ignore: comment_references
/// [SystemChannels.navigation].
///
/// The default implementation is to call the [didPushRoute] directly with the
/// [RouteInformation.uri].
@override
@protected
@mustCallSuper
Future<bool> didPushRouteInformation(
    RouteInformation routeInformation) async {
  // 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.didPushRouteInformation(routeInformation);
    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;
}