didStopUserGesture method Null safety

  1. @override
void didStopUserGesture()
override

User gesture is no longer controlling the Navigator.

Paired with an earlier call to didStartUserGesture.

Implementation

@override
void didStopUserGesture() {
  if (navigator!.userGestureInProgress) {
    return;
  }

  // When the user gesture ends, if the user horizontal drag gesture initiated
  // the flight (i.e. the back swipe) didn't move towards the pop direction at
  // all, the animation will not play and thus the status update callback
  // _handleAnimationUpdate will never be called when the gesture finishes. In
  // this case the initiated flight needs to be manually invalidated.
  bool isInvalidFlight(_HeroFlight flight) {
    return flight.manifest.isUserGestureTransition
        && flight.manifest.type == HeroFlightDirection.pop
        && flight._proxyAnimation.isDismissed;
  }

  final List<_HeroFlight> invalidFlights = _flights.values
    .where(isInvalidFlight)
    .toList(growable: false);

  // Treat these invalidated flights as dismissed. Calling _handleAnimationUpdate
  // will also remove the flight from _flights.
  for (final _HeroFlight flight in invalidFlights) {
    flight._handleAnimationUpdate(AnimationStatus.dismissed);
  }
}