v0.4.1newton_particles
Crie animações impressionantes com emissoras de partículas configuráveis. Adicione efeitos como chuva, fumaça e muito mais ao seu aplicativo Flutter!
Um Emissor de Partículas Fácil de Usar
^1.0.4^1.18.0{"sdk":"flutter"}^4.5.1^2.1.4^4.0.0{"sdk":"flutter"}^10.0.0Texto original em inglês. Visite o GitHub para a versão atual.
Newton is a highly configurable particle emitter package for Flutter, now with advanced support for both deterministic and physics-based animations. With Newton, you can create captivating animations such as rain, smoke, explosions, and more, along with realistic physics-driven effects like gravity and collisions. This allows you to easily add both visually stunning and physically accurate effects to your Flutter applications, enhancing the user experience with dynamic and interactive animations.
ezgif-2-55326df4fb
Highly Configurable: Newton offers an extensive range of options to fine-tune your particle animations. You can adjust particle appearance, behavior, movement, and physics properties, providing complete control over your animations.
Interactive Animation Configurator: Create your particle animations visually using the included app configurator. Experiment with different settings, preview animations in real-time, and copy the generated code directly into your project.
Custom Particle Design: Design your particle effects to seamlessly integrate with your app’s aesthetic. Use custom shapes, colors, and sizes to craft truly unique animations that suit your needs.
Comprehensive Documentation: Detailed guides and examples are available to help you easily create popular particle effects like rain, smoke, and explosions.
Widget Collisions: Particles can interact with Flutter widgets using
NewtonCollider, creating engaging interactive effects with accurate physics
including support for rounded corners.
Efficient Performance: Newton is optimized for performance, ensuring smooth animations even on lower-end devices without compromising on visual quality.
To use Newton, simply add it as a dependency in your pubspec.yaml file:
dependencies:
newton_particles: ^0.4.1
Then, run flutter pub get to fetch the package.
If you're building for web with WASM and using physics effects, you need to add a helper script to your web/index.html file. Add this script before the flutter_bootstrap.js script:
<body>
<script>
window._dynamicImport = (path) => import(path);
</script>
<script src="flutter_bootstrap.js" async></script>
</body>
This helper is required for Chipmunk2D's WASM module to load properly on web.
build_runner when prebuilt native libraries were missing. See issue #51 and issue #52.forge2d, you'll need to update your code.RelativisticEffect is now PhysicsEffect and RelativisticEffectConfiguration is now PhysicsEffectConfiguration for better clarity. The old names are deprecated.PhysicsProperties, VisualProperties, EmissionProperties, etc.) for better type safety and code organization. See the Migration Guide for upgrade instructions.NewtonCollider widget allows particles to collide with Flutter widgets! Create interactive effects where particles bounce off UI elements with accurate physics, including support for rounded corners, friction, and restitution.debugDataStream for tracking active particles and performance metrics.clearEffects() not triggering widget rebuildsimport 'package:newton_particles/newton_particles.dart';
Newton widget and add it to your Flutter UI with the desired
effects:Newton(
// Add any kind of effects to your UI
// For example:
effectConfigurations: [
PhysicsEffectConfiguration(
physicsProperties: const PhysicsProperties(
gravity: Gravity.earthGravity,
angle: NumRange.single(90),
velocity: NumRange.between(Velocity.stationary, Velocity.stationary),
),
visualProperties: const VisualProperties(
endScale: NumRange.single(1),
fadeOutThreshold: NumRange.between(0.6, 0.8),
),
emissionProperties: const EmissionProperties(
origin: Offset.zero,
maxOriginOffset: Offset(1, 0),
particleLifespan: DurationRange.between(Duration(seconds: 7), Duration(seconds: 10)),
),
particleConfiguration: const ParticleConfiguration(
shape: CircleShape(),
size: Size(5, 5),
),
),
],
)
Try our effect configurator to tweak your effect and copy the generated code directly into your project.
For a quick start, here's an example of creating a simple rain effect using Newton:
import 'package:flutter/material.dart';
import 'package:newton_particles/newton_particles.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await initializeNewton();
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(title: Text('Newton Rain Example')),
body: Newton(
effectConfigurations: [
PhysicsEffectConfiguration(
physicsProperties: const PhysicsProperties(
gravity: Gravity.earthGravity,
angle: NumRange.single(90),
velocity: NumRange.between(Velocity.stationary, Velocity.stationary),
),
visualProperties: const VisualProperties(
endScale: NumRange.single(1),
fadeOutThreshold: NumRange.between(0.6, 0.8),
),
emissionProperties: const EmissionProperties(
origin: Offset.zero,
maxOriginOffset: Offset(1, 0),
particleLifespan: DurationRange.between(Duration(seconds: 7), Duration(seconds: 10)),
),
particleConfiguration: const ParticleConfiguration(
shape: CircleShape(),
size: Size(5, 5),
),
),
],
),
),
);
}
}
For detailed documentation and examples, visit the Newton Documentation.
We welcome contributions from the community! If you find any issues or have ideas for improvements, feel free to open an issue or submit a pull request on GitHub.
This project is licensed under the MIT License.
Note: This package is under active development, and breaking changes might be introduced in future versions until a stable 1.0.0 release. Please review the changelog when updating versions.