in Education by
I'm trying to re-play a Flare animation in Flutter. Not loop the animation when it has complete. I want an animation to be played on demand, the same animation. When I switch between animations it works fine when just swapping the string and calling setState. Is there a simple way to do this. Here's what I'm currently doing. class _FlareDemoState extends State { String animationToPlay = 'activate'; @override Widget build(BuildContext context) { print('Animation to play: $animationToPlay'); return Scaffold( backgroundColor: Colors.purple, body: GestureDetector( onTap: () { setState(() { }); }, child: FlareActor('assets/button-animation.flr', animation: animationToPlay))); } } My logs result when I tap the animation I/flutter (18959): Animation to play: activate I/flutter (18959): Animation to play: activate I/chatty (18959): uid=10088(com.example.flare_tutorial) Thread-2 identical 2 lines I/flutter (18959): Animation to play: activate I/flutter (18959): Animation to play: activate I/chatty (18959): uid=10088(com.example.flare_tutorial) Thread-2 identical 7 lines I/flutter (18959): Animation to play: activate I/flutter (18959): Animation to play: activate Reloaded 2 of 495 libraries in 672ms. I/flutter (18959): Animation to play: activate Everything is called, it plays the first time, but after that the animation doesn't replay. JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
A cleaner way to do this is using a custom FlareController. There's a concrete FlareControls implementation that fits this use case nicely. class _MyHomePageState extends State { // Store a reference to some controls for the Flare widget final FlareControls controls = FlareControls(); void _playSuccessAnimation() { // Use the controls to trigger an animation. controls.play("success"); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text(widget.title), ), body: FlareActor("assets/Teddy.flr", animation: "idle", fit: BoxFit.contain, alignment: Alignment.center, // Make sure you use the controls with the Flare Actor widget. controller: controls), floatingActionButton: FloatingActionButton( onPressed: _playSuccessAnimation, tooltip: 'Play', child: Icon(Icons.play_arrow), ), ); } } Note that this example also plays an idle background animation which loops. Any call to FlareControls.play will mix the incoming animation over this background idle animation. You simply omit the animation: "idle" argument if you don't want/need a background animation. Full example here: https://github.com/luigi-rosso/flare_controls

Related questions

0 votes
    I am trying to handle 3 different states in my app, in the initState of my home, I call the ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 5, 2022 in Education by JackTerrance
0 votes
    I need to build a pop up dialog box in my app. I am using Dialog class and wrapped it with ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 3, 2022 in Education by JackTerrance
0 votes
    I am adding an background image to the Splash screen, but is not rendering the image. Sometime it load ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 2, 2022 in Education by JackTerrance
0 votes
    I'm working on a program that displays a list from an SQFlite table. The future for the snapshot ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 30, 2022 in Education by JackTerrance
0 votes
    I'm new to flutter and can't resolve the issue. Your application could not be compiled, because its ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 17, 2022 in Education by JackTerrance
0 votes
    I'm following the setup guide here and after I unzip flutter and run flutter doctor I get the following ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 15, 2022 in Education by JackTerrance
0 votes
    I'm new to flutter and can't resolve the issue. Your application could not be compiled, because its ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 15, 2022 in Education by JackTerrance
0 votes
    I have this operation EventModel data = EventModel(_nameEvent, _passEvent, _localEvent, _dateEventString); HashMap ... for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 13, 2022 in Education by JackTerrance
0 votes
    I'm getting Authorization failure when trying to display a map in a flutter project using the google maps ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 7, 2022 in Education by JackTerrance
0 votes
    Animation example link: https://drive.google.com/open?id=1M5UBylFj0_8mtOEQT7jjsPN9DcCjyfPI I want to show my app ... for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 26, 2022 in Education by JackTerrance
0 votes
    I'm using the official Google Maps Flutter plugin to show maps and it works perfectly well but now I ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 21, 2022 in Education by JackTerrance
0 votes
    I'm new to Flutter Redux, I got a problem and I have no idea how to deal with it at all! ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 20, 2022 in Education by JackTerrance
0 votes
    I'm using flutter_map package and I need to draw path between 2 marker. I know map_view package provided ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 20, 2022 in Education by JackTerrance
0 votes
    I want to get access to the pubspec.yaml and read its properties from dart code in my Flutter application ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 17, 2022 in Education by JackTerrance
0 votes
    Video does not capture in the right orientation when running the Camera Plugin example app on my iPhone X in Landscape. It works well ... .0+1 environment: sdk: ">=2.0.0-dev.68.0...
asked Apr 12, 2022 in Education by JackTerrance
...