funwithflutter / flutter_confetti

A Flutter widget that shoots confetti all over the screen.
https://pub.dev/packages/confetti
MIT License
439 stars 79 forks source link

Feature request: Add spread option #60

Open erf opened 2 years ago

erf commented 2 years ago

A spread option would be nice. E.g. [0, 1], where 0 is no spread, that is particles are shot in a line, where 1 is 360 deg spread.

You still should be able to randomize the spread, so perhaps a randomize option could also be added, e.g. [0, 1] where 0 is no random, that is always in a line and 1 is full random, e.g. 360 deg spread even when spread is 0. Or you could add a spread range e.g. [0.2, 0.5], so spread in between these values adding a random element in between.

An option to determine the spread of the starting position between the particles would also be nice.

Also, a variation of the particle rotation could perhaps be nice, and perhaps disable Z rotation all together.

jpSimkins commented 2 years ago

YES! Man, I have been playing with all the options just to find out that there is no way to adjust the spread. Really disappointing. Hopefully this will get added :pray:

eEQK commented 2 years ago

as a temporary workaround, you could use many ConfettiWidgets with a single controller (so they all fire at the same time) and slightly change blastDirection for each of the widgets

I wanted to get a blast from bottom center that will cover more or less the whole page, so I created 3 widgets with these directions:

My build method implementation ```dart @override Widget build(BuildContext context) { return Scaffold( body: Stack( children: [ Align( alignment: Alignment.bottomCenter, child: ConfettiWidget( confettiController: _controller, blastDirection: -pi / 2 + 0.15, emissionFrequency: 0, numberOfParticles: 20, maxBlastForce: 120, minBlastForce: 60, ), ), Align( alignment: Alignment.bottomCenter, child: ConfettiWidget( confettiController: _controller, blastDirection: -pi / 2, emissionFrequency: 0, numberOfParticles: 20, maxBlastForce: 120, minBlastForce: 60, ), ), Align( alignment: Alignment.bottomCenter, child: ConfettiWidget( confettiController: _controller, blastDirection: -pi / 2 - 0.15, emissionFrequency: 0, numberOfParticles: 20, maxBlastForce: 120, minBlastForce: 60, ), ), ], ), ); } ```
mrgithub commented 9 months ago

This would be great as confetti seems to suck up memory after a while