【问题标题】:FadeTransition not showingFadeTransition 不显示
【发布时间】:2019-08-07 09:30:39
【问题描述】:

A video is better that a thousand of words

我想要在信息卡构建时进行淡入淡出过渡 所以这就是我所做的:

 Builder(
   builder:(context){ 
     return _currentItem == 1 ? FadeTransition(
       opacity: fadeAnimation,
         child: new HotelAdditionnalInfo(),
        )
        :
        FadeTransition(
         opacity: fadeAnimation,
         child: new FlightAdditionnalInfo(),
        )
       ;
     }
  ) 

对于动画参数:

class _BookingsState extends State<Bookings> with SingleTickerProviderStateMixin {
  int _currentItem = 0;
  AnimationController animationController;
  Animation fadeAnimation;

  @override
  void initState() {
    animationController = AnimationController(vsync: this, duration: Duration(milliseconds: 1000));
    fadeAnimation = Tween(begin: 0.0, end: 1.0).animate(animationController);
    animationController.forward();
    super.initState();
  }

动画不显示。我可能做错了什么,但我不知道是什么:/

【问题讨论】:

    标签: flutter dart


    【解决方案1】:

    嗯,我找到了一个可以完成这项工作的小部件:

    AnimatedCrossFade(
                duration: const Duration(milliseconds: 500),
                firstChild: new HotelAdditionnalInfo(),
                secondChild: new FlightAdditionnalInfo(),
                crossFadeState: _currentItem == 1 ? CrossFadeState.showFirst : CrossFadeState.showSecond,
              )
    

    但它消除了我内容的阴影。

    之前: 之后:

    有人知道这个小部件是否需要某种容器吗?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-12-02
      • 1970-01-01
      • 2019-11-29
      • 1970-01-01
      • 1970-01-01
      • 2021-11-07
      • 1970-01-01
      相关资源
      最近更新 更多