kalismeras61 / flutter_page_transition

This is Flutter Page Transition Package
BSD 2-Clause "Simplified" License
471 stars 56 forks source link

Animation for only one way? #23

Closed rignaneseleo closed 3 years ago

rignaneseleo commented 4 years ago

How can I use the animation only to open a page and not when it closes?

Thanks and congrats for the good job.

spencerchubb commented 3 years ago

This might be a bit late but you'll want to wrap your page in a WillPopScope

I could explain the details here but the resources already exist on google

impure commented 3 years ago

Add this to your navigator.dart (packages/flutter/lib/src/widgets/navigator.dart) (in NavigatorState).

  Future<void> removeTop() {
    assert(!_debugLocked);
    assert(() {
      _debugLocked = true;
      return true;
    }());

    int index = _history.length - 1;
    while (index >= 0) {
      if (_history[index].isPresent) {
        _history[index].remove();
        break;
      }
    }
    _flushHistoryUpdates();

    assert(() {
      _debugLocked = false;
      return true;
    }());
  }

And then call it: Navigator.of(context).removeTop();