flutter Custom PageRouteBuilder - PullRequest
       0

flutter Custom PageRouteBuilder

0 голосов
/ 17 июня 2020

Custom Route, как этот :

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 , для навигации PageB с помощью FadeRouteBuilder ,

, когда я открываю pageB , Я перетаскиваю список PageA и удерживаю ,, когда PageB закрыто , CustomScrollView не может коснуться , недействительно.

1 Ответ

0 голосов
/ 18 июня 2020

Я использую переменную, чтобы определить, закрыта ли страница B。 enter image description here

Хотя это решает проблему, оно недостаточно элегантно. Если есть лучшее решение, пожалуйста ответь мне. спасибо

...