颤抖的自定义PageRouteBuilder

时间:2020-06-17 12:55:56

标签: flutter

这样的自定义路线:

class FadeRouteBuilder extends PageRouteBuilder {
  final Widget page;
  final int duration;


  FadeRouteBuilder({this.page, this.duration = 1000})
      : super(
          transitionDuration: Duration(milliseconds: duration),
          //Page builder doesn't do anything special, just return the ui.page we were passed in.
          pageBuilder: (context, animation, secondaryAnimation) => page,
          //transitionsBuilder builds 2 nested transitions, one for transitionIn (animation), and one for transitionOut (secondaryAnimation)
          transitionsBuilder: (context, animation, secondaryAnimation, child) {
            return FadeTransition(
                //Transition from 0 - 1 when coming on the screen
                opacity: Tween<double>(begin: 0, end: 1).animate(animation),
                child: FadeTransition(
                  //Transition from 1 to 0 when leaving the screen
                  opacity: Tween<double>(begin: 1, end: 0)
                      .animate(secondaryAnimation),
                  child: child,
                ));
          },
        );
}

包含CustomScrollView的页面是PageA,通过FadeRouteBuilder导航到PageB,

当我弹出pageB时,我拖动并按住PageA列表,当PageB关闭时,CustomScrollView无法点击,无效。

1 个答案:

答案 0 :(得分:0)

我使用一个变量来确定B页是否关闭。 enter image description here

虽然可以解决问题,但不够优雅, 如果有更好的解决方案,请回答我。 谢谢