particular 0.3.0 particular: ^0.3.0 copied to clipboard
The Particular is a high performance particle effects flutter widget.
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:particular/particular.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({super.key});
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
// Add controller to change particle
final _particleController = ParticularController();
@override
void initState() {
_loadParticleAssets();
super.initState();
}
// Load configs and texture of particle
Future<void> _loadParticleAssets() async {
// Load particle configs file
String json = await rootBundle.loadString("assets/particle.json");
final configsData = jsonDecode(json);
// add particle layer
_particleController.addLayer(configsData: configsData);
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
backgroundColor: Colors.black,
body: Particular(
controller: _particleController,
),
),
);
}
}