atmospheric_particles 0.2.4 copy "atmospheric_particles: ^0.2.4" to clipboard
atmospheric_particles: ^0.2.4 copied to clipboard

A lightweight and customizable Flutter package for creating beautiful particle animations and atmospheric effects in the background of any widget.

example/main.dart

import 'package:flutter/material.dart';
import 'package:atmospheric_particles/atmospheric_particles.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(
          seedColor: Colors.deepPurple,
        ),
      ),
      home: const MyHomePage(),
    );
  }
}

List<Color> colors = [
  Colors.red,
  Colors.orange,
  Colors.yellow.shade600,
  Colors.green,
  Colors.blue,
  Colors.deepPurple,
  Colors.purple,
];

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key});

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  bool _particlesInFront = false;
  int _trailLength = 0;
  ParticleShape _particleShape = ParticleShape.circle;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: SafeArea(
        child: Center(
          child: SingleChildScrollView(
            child: Column(
              children: <Widget>[
                Row(
                  mainAxisAlignment: MainAxisAlignment.center,
                  children: [
                    const Text('Particles in Front'),
                    Switch(
                      value: _particlesInFront,
                      onChanged: (value) {
                        setState(() {
                          _particlesInFront = value;
                        });
                      },
                    ),
                  ],
                ),
                Row(
                  mainAxisAlignment: MainAxisAlignment.center,
                  children: [
                    const Text('Trail Length:'),
                    Slider(
                      value: _trailLength.toDouble(),
                      min: 0,
                      max: 50,
                      divisions: 50,
                      label: _trailLength.round().toString(),
                      onChanged: (double value) {
                        setState(() {
                          _trailLength = value.toInt();
                        });
                      },
                    ),
                    Text(_trailLength.toString()),
                  ],
                ),
                Row(
                  mainAxisAlignment: MainAxisAlignment.center,
                  children: [
                    const Text('Particle Shape:'),
                    DropdownButton<ParticleShape>(
                      value: _particleShape,
                      onChanged: (ParticleShape? newValue) {
                        if (newValue != null) {
                          setState(() {
                            _particleShape = newValue;
                          });
                        }
                      },
                      items: ParticleShape.values
                          .map<DropdownMenuItem<ParticleShape>>(
                              (ParticleShape value) {
                        return DropdownMenuItem<ParticleShape>(
                          value: value,
                          child: Text(value.toString().split('.').last),
                        );
                      }).toList(),
                    ),
                  ],
                ),
                SizedBox(
                  height: 100,
                  width: double.infinity,
                  child: AtmosphericParticles(
                    fadeDirection: FadeDirection.top,
                    childAlignment: AlignmentGeometry.center,
                    particlesInFront: _particlesInFront,
                    trailLength: _trailLength,
                    particleShape: _particleShape,
                    child: const Text(
                      'Fade from Top',
                      style: TextStyle(
                        fontSize: 24,
                        fontWeight: FontWeight.w400,
                      ),
                    ),
                  ),
                ),
                const SizedBox(
                  height: 100,
                  width: double.infinity,
                  child: AtmosphericParticles(
                    fadeDirection: FadeDirection.bottom,
                    particleColor: Colors.amber,
                    childAlignment: AlignmentGeometry.center,
                    child: Text(
                      'Fade from Bottom',
                      style: TextStyle(
                        fontSize: 24,
                        fontWeight: FontWeight.w400,
                      ),
                    ),
                  ),
                ),
                const SizedBox(
                  height: 100,
                  width: double.infinity,
                  child: AtmosphericParticles(
                    fadeDirection: FadeDirection.left,
                    particleColor: Colors.lightBlue,
                    childAlignment: AlignmentGeometry.center,
                    child: Text(
                      'Fade from Left',
                      style: TextStyle(
                        fontSize: 24,
                        fontWeight: FontWeight.w400,
                      ),
                    ),
                  ),
                ),
                const SizedBox(
                  height: 100,
                  width: double.infinity,
                  child: AtmosphericParticles(
                    fadeDirection: FadeDirection.right,
                    particleColor: Colors.lightGreen,
                    childAlignment: AlignmentGeometry.center,
                    child: Text(
                      'Fade from Right',
                      style: TextStyle(
                        fontSize: 24,
                        fontWeight: FontWeight.w400,
                      ),
                    ),
                  ),
                ),
                for (int i = 0; i < 7; i++)
                  SizedBox(
                    height: 100,
                    width: double.infinity,
                    child: AtmosphericParticles(
                      particleColor: colors[i % colors.length],
                      childAlignment: AlignmentGeometry.center,
                      child: const Text(
                        'Hello world!',
                        style: TextStyle(
                          fontSize: 24,
                          fontWeight: FontWeight.w400,
                        ),
                      ),
                    ),
                  ),
              ],
            ),
          ),
        ),
      ),
    );
  }
}
7
likes
0
points
38
downloads

Publisher

unverified uploader

Weekly Downloads

A lightweight and customizable Flutter package for creating beautiful particle animations and atmospheric effects in the background of any widget.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter

More

Packages that depend on atmospheric_particles