在SizeTransition上颤振更改开始动画

时间:2020-04-14 15:35:21

标签: flutter flutter-layout flutter-animation

在我的应用程序中实现的这段代码中,我想更改SizeTransition动画的开始位置,但是我无法找到有关此内容的任何文件

SizeTransition(
  sizeFactor: CurvedAnimation(parent: _animationController,curve: Curves.easeInOut),
  axisAlignment: 0.0,
  child: Row(
    mainAxisAlignment: MainAxisAlignment.spaceBetween,
    children: <Widget>[

    ],
  ),
),

因为SizeTransition将从zero开始,而我想将其更改为0.5,对此问题有任何机构意见吗?

1 个答案:

答案 0 :(得分:1)

要更改开始位置,您需要更改偏移量:

SlideTransition(
  position: Tween<Offset>(
    begin: const Offset(-1, 0), 
    end: Offset.zero,
  ).animate(animation),
  child: child,
)


  // from left
  position: Tween<Offset>(
    begin: const Offset(-1, 0), 
    end: Offset.zero,
  ).animate(animation),


  // from right
  position: Tween<Offset>(
    begin: const Offset(1, 0), 
    end: Offset.zero,
  ).animate(animation),

  // from bottom
  position: Tween<Offset>(
        begin: const Offset(0, 1),
    end: Offset.zero,
  ).animate(animation),


  // from top
  position: Tween<Offset>(
        begin: const Offset(0, -1),
    end: Offset.zero,
  ).animate(animation),