double _size = 0;
Color _color = Colors.white;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(),
floatingActionButton: FloatingActionButton(
child: Icon(Icons.refresh),
onPressed: () {
Timer.periodic(Duration(milliseconds: 10), (timer) {
if (timer.tick > 100) timer.cancel();
if (timer.tick == 1) _color = Colors.blue;
setState(() => _size += 20);
});
},
),
body: Stack(
children: [
AnimatedContainer(
duration: Duration(seconds: 5),
width: _size,
height: _size,
alignment: Alignment.center,
decoration: BoxDecoration(color: _color, shape: BoxShape.circle),
),
Placeholder(),
],
),
);
}
当前输出:
预期输出:
谁能告诉我该怎么做,我是Flutter的新手。也许我的方法不正确,应该使用backgroundColor
的{{1}}属性还是其他?