Snowfall or Anythings
Make it snow in your Flutter app. Or rain hearts, Christmas trees, Santa, leaves, stars, confetti⦠anything.
Falling particle effects in one lightweight widget: snowfall, rain, autumn leaves, Valentine's hearts, Christmas decorations, party confetti, or any widget, emoji or image you want. Mix up to 5 elements and choose the percentage of each one.
βΆοΈ Try the live demo Β· π Read how it was built Β· π¦ pub.dev
| Christmas mix (snow + stars + π π π) | Seasonal presets | Overlay: taps still work | Live demo app |
|---|---|---|---|
![]() |
![]() |
![]() |
![]() |
π How was it built? Time-based animation, painting hundreds of particles without rebuilding widgets, mixing shapes and emojis with percentages, and evolving a published package without breaking changes. Read the full article on the blog β
Features
- βοΈ Snow or anything: 6 built-in shapes (snowflake, circle, star, heart, leaf, raindrop) or any widget (images, icons, emojis)
- π Mix up to 5 elements at once, with the percentage of each one (e.g. 60% snow, 20% stars, 10% Santa, 10% trees)
- β‘ Lightweight: particles are painted directly on the canvas, with no widget rebuild per frame
- β±οΈ Same speed on every screen (60 Hz, 90 Hz, 120 Hz), with an optional FPS cap (
maxFps) to save battery - π Overlay friendly: put it on top of your screen and buttons, fields and lists below keep working
- π Change anything at runtime (colors, sizes, amount, mix), no
Keytricks needed - π― Custom painters for your own shapes
- π§© Zero dependencies, pure Flutter: Android, iOS, web, Windows, macOS and Linux
Installation
flutter pub add snowfall_or_anythings
Or add it to your pubspec.yaml:
dependencies:
snowfall_or_anythings: ^0.0.9
Quick start
import 'package:snowfall_or_anythings/snowfall_or_anythings.dart';
// Snow falling over your page
Stack(
children: [
const MyPageContent(),
const Positioned.fill(
child: SnowfallOrAnythings(particleType: ParticleType.snowflake),
),
],
)
That's it. The widget fills the space it's given, and touches pass through to your content.
Mixing elements (up to 5) π
Use particleVariants to make different things fall together. Each ParticleVariant uses a
built-in shape (type) or any widget (widget), and weight sets its share:
SnowfallOrAnythings(
numberOfParticles: 150,
particleVariants: const [
ParticleVariant(type: ParticleType.snowflake, weight: 60), // 60%
ParticleVariant(type: ParticleType.star, color: Colors.amber, weight: 20), // 20%
ParticleVariant(widget: FittedBox(child: Text('π
')), size: 28, weight: 10),
ParticleVariant(widget: FittedBox(child: Text('π')), size: 28, weight: 10),
],
)
- Weights are proportional (
60, 20, 10, 10is the same as6, 2, 1, 1) and the split is exact: with 150 particles you get 90 snowflakes, 30 stars, 15 Santas and 15 trees. color,sizeandspeedare optional per variant and default to the widget'sparticleColor,particleSizeandparticleSpeed.- The same shape can appear more than once with different colors (autumn leaves in orange, red and yellow).
- Up to
SnowfallOrAnythings.maxParticleVariants(5) entries are used. - With a
customPainter, the variants still define how many particles of each kind exist; useparticle.variantIndexto draw each one differently.
Recipes
βοΈ Snowfall
SnowfallOrAnythings(
numberOfParticles: 200,
particleSize: 4.0,
particleSpeed: 0.8,
particleType: ParticleType.snowflake,
)
β€οΈ Falling hearts (Valentine's Day)
SnowfallOrAnythings(
numberOfParticles: 80,
particleSize: 12.0,
particleVariants: const [
ParticleVariant(type: ParticleType.heart, color: Colors.redAccent),
ParticleVariant(type: ParticleType.heart, color: Colors.pinkAccent),
],
)
π Autumn leaves
SnowfallOrAnythings(
numberOfParticles: 70,
particleSize: 14.0,
particleVariants: const [
ParticleVariant(type: ParticleType.leaf, color: Colors.orange),
ParticleVariant(type: ParticleType.leaf, color: Colors.redAccent),
ParticleVariant(type: ParticleType.leaf, color: Colors.amber),
],
)
π§ Rain
SnowfallOrAnythings(
numberOfParticles: 300,
particleSize: 5.0,
particleSpeed: 6.0,
particleColor: Colors.lightBlueAccent,
particleType: ParticleType.raindrop,
)
β Stars
SnowfallOrAnythings(
numberOfParticles: 100,
particleSize: 10.0,
particleSpeed: 0.8,
particleColor: Colors.yellow,
particleType: ParticleType.star,
)
π Party confetti
SnowfallOrAnythings(
numberOfParticles: 160,
particleSpeed: 2.0,
particleVariants: const [
ParticleVariant(type: ParticleType.circular, color: Colors.yellowAccent, size: 4),
ParticleVariant(type: ParticleType.circular, color: Colors.cyanAccent, size: 4),
ParticleVariant(type: ParticleType.star, color: Colors.pinkAccent, size: 8),
ParticleVariant(widget: FittedBox(child: Text('π')), size: 28),
],
)
π§© Any widget as a particle
SnowfallOrAnythings(
numberOfParticles: 50,
particleSize: 20.0,
particleSpeed: 1.5,
particleWidget: const Icon(Icons.favorite, color: Colors.red),
)
// or an image
SnowfallOrAnythings(
numberOfParticles: 100,
particleSize: 30.0,
particleWidget: Image.asset('assets/snowflake.png'),
)
Each widget is placed with its top-left corner at the particle position and sized
particle.size Γ particle.size. Widget particles keep receiving touches, so you can make
them tappable (see the "Widget particles" demo).
π― Custom painter
Draw your own shapes. The painter receives all particles (position, size, color, variantIndex):
SnowfallOrAnythings(
particleColor: Colors.green,
numberOfParticles: 150,
particleSize: 10.0,
particleSpeed: 2.0,
customPainter: ({required particles}) => SquarePainter(particles),
)
class SquarePainter extends CustomPainter {
SquarePainter(this.particles);
final List<Particle> particles;
@override
void paint(Canvas canvas, Size size) {
final paint = Paint();
for (final particle in particles) {
paint.color = particle.color;
canvas.drawRect(
Rect.fromCenter(
center: Offset(particle.x, particle.y),
width: particle.size,
height: particle.size,
),
paint,
);
}
}
@override
bool shouldRepaint(covariant CustomPainter oldDelegate) => true;
}
Particles are centered on
(particle.x, particle.y)by the built-in painters.
π Saving battery
By default the animation follows the display refresh rate. Use maxFps to cap it: the
falling speed stays the same, only the smoothness changes.
SnowfallOrAnythings(
numberOfParticles: 300,
particleType: ParticleType.snowflake,
maxFps: 30,
)
Particle types
| Type | Description | Best for |
|---|---|---|
βοΈ snowflake |
6-branched snowflake with details | Winter, Christmas |
βͺ circular |
Simple filled circles | Snow dust, bubbles, confetti |
β star |
5-pointed stars with random orientation | Night sky, magic, celebrations |
β€οΈ heart |
Heart shapes | Valentine's Day, love themes |
π leaf |
Leaves with veins and random tilt | Autumn, nature |
π§ raindrop |
Teardrop shapes | Rain, water |
API reference
SnowfallOrAnythings
| Parameter | Type | Default | Description |
|---|---|---|---|
numberOfParticles |
int |
200 |
Number of particles on screen |
particleColor |
Color |
Colors.white |
Color of built-in shapes |
particleSize |
double |
4.0 |
Base size: each particle gets a random size from 2 to particleSize + 2 (radius for built-in shapes, width/height for widgets) |
particleSpeed |
double |
1.0 |
Falling speed: each particle gets a random speed from 1 to particleSpeed + 1 px per frame at 60 FPS |
particleType |
ParticleType |
snowflake |
Built-in shape |
particleWidget |
Widget? |
null |
Widget used as particle |
particleVariants |
List<ParticleVariant>? |
null |
Up to 5 kinds of particles falling together, each with its share |
customPainter |
Function? |
null |
Your own painter: ({required particles}) => CustomPainter |
maxFps |
double? |
null |
Maximum animation updates per second (null = display refresh rate) |
frameRateMs |
int |
16 |
Deprecated, use maxFps |
ParticleVariant
| Parameter | Type | Default | Description |
|---|---|---|---|
type |
ParticleType? |
null |
Built-in shape (falls back to particleType) |
widget |
Widget? |
null |
Widget used as particle (use either type or widget) |
color |
Color? |
null |
Color for built-in shapes (falls back to particleColor) |
size |
double? |
null |
Base size (falls back to particleSize) |
speed |
double? |
null |
Speed (falls back to particleSpeed) |
weight |
double |
1 |
Proportional share of particles, must be > 0 |
Performance tips
- Fewer particles on small devices:
numberOfParticles: MediaQuery.sizeOf(context).width > 600 ? 200 : 100 - Cap the frame rate for battery:
maxFps: 30 - Prefer built-in shapes for large amounts;
circularis the cheapest - Widget particles are positioned without rebuilds, but each widget still costs more than a painted shape: keep them in the tens, not hundreds
Migrating from 0.0.7
Nothing breaks. Two things are deprecated and will be removed in a future major version:
frameRateMsnever limited the frame rate: usemaxFpsinstead (values other than16are converted automatically)ParticlePainter: useCircularParticlePainter
See the CHANGELOG for all fixes and improvements.
Live demo & example app
Try every feature in your browser at snowfall.valdir.dev.br.
The same app lives in the example folder: playground with every parameter,
Christmas mix with percentages, seasonal presets, overlay, tappable widget particles,
custom painter and FPS control.
Author
Created by Valdir Giorgi.
π Want to know how this package was designed and built? Read the article on the blog.
Contributing
Contributions are welcome! Feel free to open a Pull Request. Found a bug or have an idea? Open an issue.
License
MIT. See LICENSE.



