Skip to content

Add a TweenAnimationBuilder.repeat API #174014

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

bernaferrari
Copy link
Contributor

@bernaferrari bernaferrari commented Aug 19, 2025

Implements / Close #174011

Probably there are 400 LOC of comments + tests, so this removes more code than adds.

diff

@github-actions github-actions bot added framework flutter/packages/flutter repository. See also f: labels. a: animation Animation APIs f: material design flutter/packages/flutter/material repository. f: cupertino flutter/packages/flutter/cupertino repository d: api docs Issues with https://api.flutter.dev/ d: examples Sample code and demos labels Aug 19, 2025
@bernaferrari bernaferrari force-pushed the tween branch 2 times, most recently from 53cabd8 to 3dcc5eb Compare August 19, 2025 06:27
@github-actions github-actions bot added the a: text input Entering text in a text field or keyboard related problems label Aug 19, 2025
Comment on lines 146 to 147
/// Unlike the default constructor, [onEnd] is not supported for repeating
/// animations since they never end.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: I'd consider dropping this line - calling out something that's not present might confuse users.

/// * [AnimationController.repeat], which this constructor replaces for simple use cases.
/// * [TweenAnimationBuilder], the default constructor for single animations.
///
/// ## Ownership
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you move the Ownership section up above the code samples?

Comment on lines 194 to 199
/// ## Ownership
///
/// The [TweenAnimationBuilder] takes full ownership of the provided [tween]
/// instance and mutates it. Once a [Tween] has been passed to a
/// [TweenAnimationBuilder], its properties should not be accessed or changed
/// anymore to avoid interference with the [TweenAnimationBuilder].
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This content mirrors but is slightly different from the "Ownership of the Tween" content on TweenAnimationBuilder. I'd consider making a template out of the original content and just use the template here.

https://github.com/flutter/flutter/blob/6cbd98adc517ca7a20c724c4f0c5a5a385b95f74/packages/flutter/lib/src/widgets/tween_animation_builder.dart#L58C1-L67C34

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the issue of making a template (now) where it is a separate component is that I can't repeat "The [TweenAnimationBuilder] takes full ownership" unless it accepts variable so might make sense to repeat now :( or just omit or duplicate.

bool paused = false,
required this.builder,
this.child,
}) : _isRepeating = true,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oof.. This is not as nice as I had hoped. Maybe this would be better as a separate RepeatedTweenAnimationBuilder widget?

@bernaferrari bernaferrari force-pushed the tween branch 4 times, most recently from dee8e52 to 6a1920f Compare August 21, 2025 16:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a: animation Animation APIs a: text input Entering text in a text field or keyboard related problems d: api docs Issues with https://api.flutter.dev/ d: examples Sample code and demos f: cupertino flutter/packages/flutter/cupertino repository f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a RepeatedTweenAnimationBuilder API
2 participants