Flutter粒子特效插件ultimate_particle_fx的使用
Flutter粒子特效插件ultimate_particle_fx的使用
Ultimate Particle FX 是一个为您的 Flutter 应用程序定制的粒子效果插件。
如何使用
Ultimate Particle FX 可以作为一个简单的 widget 使用。
在您的 pubspec.yaml
文件中添加此依赖,并使用最新版本:
dependencies:
ultimate_particle_fx: ^latest_version
在 Dart 文件中导入插件并使用它:
import 'package:ultimate_particle_fx/ultimate_particle_fx.dart';
[@override](/user/override)
Widget build(BuildContext context) {
return Scaffold(
extendBodyBehindAppBar: true,
body: UltimateParticleFx(
neverEnding: true,
width: MediaQuery.of(context).size.width + 150,
height: MediaQuery.of(context).size.height + 150,
velocity: const Offset(0, 0),
position: const Offset(0, 0),
colors: const [Colors.green, Colors.yellow, Colors.red, Colors.blue],
maxSize: 200.0,
minSize: 5.0,
lifespan: 1000,
maxParticles: 10,
speed: 0.5,
rotation: 0,
shapes: const [
ParticleShape.circle,
ParticleShape.square,
ParticleShape.triangle,
ParticleShape.star,
ParticleShape.hexagon,
ParticleShape.diamond,
ParticleShape.pentagon,
ParticleShape.ellipse,
ParticleShape.cross,
ParticleShape.heart,
ParticleShape.arrow,
ParticleShape.cloud,
ParticleShape.octagon,
ParticleShape.custom
],
customParticleImage: const [
AssetImage('assets/images/cloud.png'),
AssetImage('assets/images/coin.png'),
NetworkImage('https://www.vhv.rs/dpng/d/397-3976228_wispy-clouds-sprite-cloud-sprite-hd-png-download.png'),
],
gradient: const LinearGradient(
colors: [Colors.orange, Colors.red],
begin: Alignment.topLeft,
end: Alignment.bottomRight,
stops: [0.0, 1.0]
),
allowParticlesExitSpawnArea: true,
spawnAreaPosition: const Offset(0, 0),
spawnPosition: SpawnPosition.random,
movementDirection: MovementDirection.random,
spawnAreaWidth: double.infinity,
spawnAreaHeight: double.infinity,
spawnAreaColor: Colors.transparent,
touchType: TouchType.push,
child: const Center(
child: Text('Ultimate Particle FX')
)
)
);
}
更多关于Flutter粒子特效插件ultimate_particle_fx的使用的实战教程也可以访问 https://www.itying.com/category-92-b0.html
1 回复