gskinner / gskinner/flutter_animate
Animation delays cause renders
- Dominant language
- Dart
- Stars
- 1.1k
- Forks
- 103
- PR merge metrics
- No merged PRs in 30d
Description
This may not be actionable but logging this just so we can track it and potentially chat about workarounds.
# Issue
When animations are delayed they force flutter to re-render at 60fps even though nothing on screen is changing.
This is due to behavior built into Flutters `Ticker` object, which drives `AnimationController`, and `flutter_animate`s implementation of delays which rely on a long-running `AnimationController` that incorporates the duration of the delay into the total duration of an animation.
Each time Ticker ticks it schedules a new frame to be rendered.
# Reproduction
This can be reproduced with a repeating distractor like this, which will put the app into a state of constant endless re-rendering.
```dart
Widget build(BuildContext context) => MaterialApp(
home: Center(
child: FlutterLogo(size: 200)
.animate(
onPlay: (c) => c.repeat(),
)
.shimmer(delay: 2.seconds, duration: 1.seconds),
),
);
```
You can observe the app in a state of constant re-render here:
https://github.com/gskinner/flutter_animate/assets/736973/2e2f5674-6f28-4b26-ae59-d7bff78f6188
# Solution
One possible idea is to create a sub-class of Ticker that exposes a `bool scheduleFrame` param and can switch between a Timer based tick and a Sheduler based tick. Not sure how feasible this is, I can try and work on a proof of concept to prove viability, and then potentially we can request some tweaks to the Flutter SDK if required.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.