Flutter Confetti 组件
一个简单的 Flutter 彩带组件
添加依赖
flutter pub add confetti
示例
代码
return Stack(
alignment: Alignment.topCenter,
children: [
Scaffold(
appBar: AppBar(
title: const Text(
"C O N F E T T I",
style: TextStyle(fontWeight: FontWeight.bold),
),
centerTitle: true,
),
body: Center(
child: MaterialButton(
onPressed: () {
if (isPlay) {
_controller.stop();
} else {
_controller.play();
}
isPlay = !isPlay;
},
color: Colors.deepPurple[100],
child: const Text("Click me"),
)),
),
组件代码
ConfettiWidget(
confettiController: _controller,
blastDirection: -pi / 2,
colors: const [Colors.deepPurple, Colors.black, Colors.yellow],
gravity: 0.7,
emissionFrequency: 0.2,
)
参考
Pub.dev : Confetti 组件
