animation always restarts in Listview.builder
Hi, i want to to add a flutter animation at the first item of a listview. so i decided to take a Listview.builder. The page is a statefull widget because i have to update the listview sometimes if a new event arrives over a websocket.
so i tried this one here:
ListView.builder(
itemCount: _events.length,
padding: const EdgeInsets.all(15.0),
itemBuilder: (context, position) {
return position == 0 && _events[position].eventID >= 0
? makeFirstCard(_events[position])
: makeCard(_events[position]);
});
//...
makeFirstCard(GameEvent event) {
return Card(
elevation: 1.0,
margin: new EdgeInsets.symmetric(horizontal: 5.0, vertical: 6.0),
child: Container(
width: double.infinity,
child: Row(
children: <Widget>[
Expanded(
flex: 0,
child: Container(
width: 100,
height: 100,
child: FlareActor(
"assets/animations/dummy.flr",
animation: "dummy",
))),
// some other text fields...
],
),
),
);
}
if i just scroll down a little bit the animation is starting from beginning. is it possible to have a animation in a listview.builder or is there a better way to do this? the length of items is dynamic and will change while the user is on this page.
[edit] this only appears on touch down the listview. after touch down, holding and moving the list the animation works as expected. [/edit]
thanks. phil
Pubspec
flare_flutter: ^1.8.3
Flutter Doctor
Doctor summary (to see all details, run flutter doctor -v): [✓] Flutter (Channel master, v1.13.7-pre.8, on Mac OS X 10.15.3 19D76, locale de-DE)
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2) [✓] Xcode - develop for iOS and macOS (Xcode 11.4) [✓] Android Studio (version 3.6) [!] IntelliJ IDEA Community Edition (version 2019.1.4) ✗ Flutter plugin not installed; this adds Flutter specific functionality. ✗ Dart plugin not installed; this adds Dart specific functionality. [!] Connected device ! No devices available
I have the same issue with a "SingleChildScrollView", and "physics" set to "AlwaysScrollableScrollPhysics()". The FlareActor is rebuilt and the animation restarts. How to avoid this behavior ? Is it a bug or the normal behavior ? I thought that the FlareActor will properly manage the animation state.
Any solution?
1 year later...