isActive property Null safety

bool isActive

Whether this route is on the navigator.

If the route is not only active, but also the current route (the top-most route), then isCurrent will also be true. If it is the first route (the bottom-most route), then isFirst will also be true.

If a higher route is entirely opaque, then the route will be active but not rendered. It is even possible for the route to be active but for the stateful widgets within the route to not be instantiated. See ModalRoute.maintainState.


bool get isActive {
  if (_navigator == null)
    return false;
  return _navigator!._history.cast<_RouteEntry?>().firstWhere(
    (_RouteEntry? e) => e != null && _RouteEntry.isRoutePredicate(this)(e),
    orElse: () => null,
  )?.isPresent == true;