gskinner / gskinner/flutter_animate
Add support for declarative playback using `end` field
- Dominant language
- Dart
- Stars
- 1.1k
- Forks
- 103
- PR merge metrics
- No merged PRs in 30d
Description
There are certain cases where it would be nice to just set the `end` value for a set of tweens, and have the tweens run when that end value changes.
For example:
```
GridView(
children: imageWidgets.map((i){
bool selected = imageWidgets.indexOf(i) == selectedIndex;
return i.animate().scale(
duration: 200.ms,
curve: Curves.easeOut,
begin: 1,
end: selected? 1.2 : 1);
})
```
We could then easily create this effect where the selected image scales in, while the previously selected image scales out. The others do nothing.
https://user-images.githubusercontent.com/736973/188086611-fff77915-6be6-4236-9b8e-54700c8533a3.mp4
Currently the easiest way to do this is still with the built in `TweenAnimationBuilder`, which is a fine API, but it cant hook into any of `Animate`s effects:
```
imageWidgets.map((i){
bool selected = imageWidgets.indexOf(i) == selectedIndex;
return TweenAnimationBuilder(
tween: Tween(begin: 1, end: selected ? 1.15 : 1),
duration: 200.ms,
curve: Curves.easeOut,
builder: (_, value, child) => Transform.scale(scale: value, child: img),
)
}
```
If you matched the declarative behavior of TAB, then the old `end` would become the new `begin` if `end` ever changes, which is quite nice for continuous effects (go from A > B > A). Changes to `begin` are ignored until the widget state is reloaded.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by comparing the requested declarative behavior with Flutter's TweenAnimationBuilder and the existing Animate effects. Verify how an end-value change should transition from the old end to the new end, including repeated changes such as A > B > A, while ignoring begin changes until widget state reloads. Done means end-driven playback works with Animate effects and matches the provided scaling example.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- dart, flutter
- Domain
- mobile
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100