这个包confetti 可能有帮助吗?在他们的示例中,他们有一种方法来绘制自定义五彩纸屑(类似于图像的星星)
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.greenAccent[200],
body: SafeArea(
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
ConfettiWidget(
confettiController: _confettiController,
createParticlePath: drawCustomConfetti,
child: ElevatedButton(
onPressed: _confettiController.play,
child: Text("show confetti")),
),
ElevatedButton(
onPressed: _confettiController.stop,
child: Text("stop showing confetti"))
],
),
),
),
);
}
//here you can draw the custom confetti
Path drawCustomConfetti(Size? size) {
final path = Path();
path.moveTo(10, 0);
path.lineTo(0, 10);
path.lineTo(-10, 0);
path.lineTo(0, -10);
path.lineTo(10, 0);
path.close();
return path;
}
这里是如何使用confetti包的代码,您可以使用该功能通过dart的Path修改形状。
this is an article on how to use path in dart
您还可以查看confetti 包以获取有关如何更改速度、爆炸方向等的更多详细信息