Comments (5)
You can use an instance FlareControls as the controller to your FlareActor widget. Take a look at how the Teddy example does this:
A more basic version:
class SomeWidgetState ...
final FlareControls _controls = FlareControls();
@override
Widget build(BuildContext context) {
return
...
FlareActor("assets/myFlare.flr",
alignment: Alignment.topCenter,
shouldClip: false,
fit: BoxFit.contain,
animation: "idle",
controller: _controls),
),
...
FlatButton(
onPressed: () {
_controls.play("success");
},
from flare-flutter.
I'm assuming this is for a non looping animation, correct?
You're right, we don't have a good way to do this right now unless you use a controller to do your own mixing.
One way to do it right now would be to use the FlareCompletedCallback to set the animation to null when it completes. Then set it back to the animation you want to play when some event occurs.
This doesn't allow you to restart the animation while it's still playing, however. If you wanted to do that you could do this hideous thing:
String _animationName = "myAnimation";
...
// when you want to restart it
setState(() {
_animationName = null;
setState(() {
_animationName = "myAnimation";
});
});
What's your use case? Maybe we can find an all together better solution that would benefit others too.
from flare-flutter.
I've been swapping between "myAnimation"
and ""
. My use case is that I don't want a looping animation but I want to trigger a play through at any time.
from flare-flutter.
Could we just wrap the flare Actor widget with a stateful widget, do the refractoring to where the class is still named FlareActor, pass in all the possible variables for FlareActor, and expose a reset method using the ugly solution Luigi offered? so the end user just has to do actor.reset(); ..?
from flare-flutter.
I'm facing a similar issue. I have a "looping" animation:
which I can start and then pause. I cannot "reset" the animation state, however.
FlareActor(
"assets/anim/success_check.flr",
animation: _animationName,
isPaused: _isPaused,
)
void _startAnimation() => setState(() {
_animationName = "Untitled";
_isPaused = false;
});
void _resetAnimState() => setState(() {
_animationName = "";
_isPaused = true;
});
from flare-flutter.
Related Issues (20)
- Migrate to null safety HOT 8
- Add debug mode HOT 1
- Migration to Null-Safety HOT 3
- Request for Clarification: Flare-Flutter vs Rive Flutter Runtime Use Cases HOT 4
- LateInitializationError HOT 8
- Null Safety for flare_dart HOT 3
- Placeholder widget while animation is loading
- 3.0.0 antialiasing no longer working HOT 13
- IK Constraints not working HOT 4
- Difference between flare-flutter and rive-flutter HOT 4
- FlutterActorImage not visible FlareActor
- Clear Memory after finish an animation HOT 2
- Can't load FlareActor.bundle on Android HOT 2
- Unhandled Exception: Exception: LateInitializationError: Field '_paint@235459774' has not been initialized HOT 2
- LateInitializationError: Field '_paint@xxxxxx' has not been initialized HOT 2
- LateInitializationError: Field '_setupAABB@43245341' has not been initialized HOT 1
- Flutter 2.10 & 3.0 throw warnings during compilation HOT 3
- Warning: Operand of null-aware operation '?.' has type 'SchedulerBinding' which excludes null. HOT 4
- update HOT 1
- Flutter3 Error HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flare-flutter.