gskinner / gskinner/flutter_animate

Single tick delay when delay=0

Open
#163 0 comments 0 reactions 0 assignees View on GitHub
wontfix
Dominant language
Dart
Stars
1.1k
Forks
103
PR merge metrics
No merged PRs in 30d

Description

Because `Future.delayed` will always delay to at least the next tick, animations with a delay of 0 don't actually begin animating until the next tick. You can see this with an animation like the following:

``` dart
foo.animate().fadeOut(duration: 0.ms)
```

In this case, the `foo` widget will display for a single frame because it renders the beginning of the animation (100% opacity) initially, then jumps to the end of the animation (and 0% opacity) the next tick.

This is solvable with a fix similar to the below in `Animate._restart`, but I'm not convinced it's worth the change. The problem is unlikely to manifest in any but the most esoteric situations (like the above), the expected behavior is a bit ambiguous (ie. the current implementation isn't clearly wrong), and having events like `onComplete` become synchronous in some cases could introduce new issues.

``` dart
void _restart() {
_delayed?.ignore();
_initController();
_updateValue();

if (widget.delay == Duration.zero) {
// this prevent a one tick flicker.
_play();
} else {
_delayed = Future.delayed(widget.delay, () => _play());
}
}
```

Similar to #152 I'm going to defer any action on this until there's real world reports.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.