flutter/packages
Simon Friis Vindum 6c78e36ccb
Fix initialization of time in repeat on AnimationController (#142887)
This PR fixes #142885.

The issue is that in `_RepeatingSimulation` the initial time is calculated as follows:

```
(initialValue / (max - min)) * (period.inMicroseconds / Duration.microsecondsPerSecond)
```

This calculation does not work in general. For instance, if `max` is 300, `min` is 100, and `initialValue` is 100 then `initialValue / (max - min)` is 1/2 when it should be 0

The current tests work by happenstance because the numbers used happen to work. To reveal the bug I've added some more tests similar to the existing ones but with different numbers.

A "side-effect" of the incorrect calculation is that if `initialValue` is 0, then the animation will always start from `min` no matter what. For instance, in one of the tests, an `AnimationController` with the value 0 is told to `repeat` between 0.5 and 1.0, and this starts the animation from 0.5. To preserve this behavior, and to more generally handle the case where the initial value is out of bounds, this PR clamps the initial value to be within the lower and upper bounds of the repetition.

Just for reference, this calculation was introduced at https://github.com/flutter/flutter/pull/25125.
2024-02-21 00:36:08 +00:00
..
flutter Fix initialization of time in repeat on AnimationController (#142887) 2024-02-21 00:36:08 +00:00
flutter_driver Fix implementation imports outside of lib (#143594) 2024-02-16 22:38:10 +00:00
flutter_goldens [gold] Always provide host ABI to gold config (#143621) 2024-02-20 21:06:01 +00:00
flutter_localizations Upgrade leak_tracker. (#143236) 2024-02-09 14:41:22 -08:00
flutter_test Introduce tone-based surfaces and accent color add-ons - Part 2 (#138521) 2024-02-20 19:01:50 +00:00
flutter_tools instead of exiting the tool, print a warning when using --flavor with an incompatible device (#143735) 2024-02-20 21:02:49 +00:00
flutter_web_plugins Upgrade leak_tracker. (#143236) 2024-02-09 14:41:22 -08:00
fuchsia_remote_debug_protocol Upgrade leak_tracker. (#143236) 2024-02-09 14:41:22 -08:00
integration_test Update dependencies in integration test (#143111) 2024-02-13 20:29:35 +00:00
analysis_options.yaml Unify analysis options (#108462) 2022-07-28 09:07:49 -07:00