在给定的代码中,RaisedButton 的 onPressed 功能可以正常工作,并将 FlatButton 移至顶部。但是,FlatButton 的 onPressed 无法正常工作。
@override
Widget build(BuildContext context) {
return Stack(
children: <Widget>[
Transform(
transform: Matrix4.translationValues(
0.0,
_translateButton.value,
0.0,
),
child: FlatButton(
onPressed: () {
print('tapped Flat button');
},
child: Text('upper'),
),
),
RaisedButton(
onPressed: () {
animate();
print('tapped Raised button');
},
child: Text('lower'))
],
);
}
当调用animate()函数时,_translatebutton的值将从0变为-60。
_animationController = AnimationController(vsync: this, duration: Duration(milliseconds: 500))
..addListener(() {
setState(() {});
});
_translateButton = Tween<double>(
begin: 0,
end: -60,
).animate(CurvedAnimation(
parent: _animationController,
curve: Interval(
0.0,
0.75,
curve: _curve,
),
));
AnimatedAlign
控制动画的开始。 - a0x2Matrix4.translationValue
的Transform
?你指的是哪个按钮?顺便问一下,为什么没有使用Transform.translate
? - pskinkshape: CircularNotchedRectangle()
不起作用。这是来自 https://medium.com/@agungsurya/create-a-simple-animated-floatingactionbutton-in-flutter-2d24f37cfbcc 的内容。 - a0x2shape: CircularNotchedRectangle()
无法正常工作。当我使用堆栈时它可以工作,但是onTap却不能正常工作。 - a0x2