Skip to content
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

feat: add optional useRepaintBoundary to Animate #47

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

S-ecki
Copy link

@S-ecki S-ecki commented Jan 28, 2023

This is a draft PR

Documentation is still open, I will add it next week when I have more time.

closes #46

@@ -176,6 +177,9 @@ class Animate extends StatefulWidget with AnimateManager<Animate> {
/// ```
final double? target;

// TODO: add documentation
Copy link
Owner

Choose a reason for hiding this comment

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

Appreciate if you take a first stab at this.

Copy link
Author

Choose a reason for hiding this comment

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

Will gladly do this tomorrow :)

@@ -320,7 +324,9 @@ class _AnimateState extends State<Animate> with SingleTickerProviderStateMixin {
for (EffectEntry entry in widget._entries) {
child = entry.effect.build(context, child, _controller, entry);
}
return reparent?.call(parent, child) ?? child;
Widget returnWidget = reparent?.call(parent, child) ?? child;
if (widget.useRepaintBoundary) return RepaintBoundary(child: returnWidget);
Copy link
Owner

Choose a reason for hiding this comment

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

instead of an additional return, I'd just add to returnWidget. I wonder if there's a better name than returnWidget also.

@@ -346,6 +353,7 @@ extension AnimateWidgetExtensions on Widget {
controller: controller,
adapter: adapter,
target: target,
useRepaintBoundary: useRepaintBoundary ?? false,
Copy link
Owner

Choose a reason for hiding this comment

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

I try really hard to not duplicate defaults in extension methods, since it creates fragility when changing them (easy to forget to update in all locations). Take a look at any of the extension methods on various effects for examples.

Copy link
Author

Choose a reason for hiding this comment

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

Really good point, pulled it out of the constructors!

@S-ecki
Copy link
Author

S-ecki commented Jan 31, 2023

@gskinner I added a first draft of the docs, let me know what you think! And feel free to change anyting obviously.

As a side note: The dart docs for parameters are only available with the "standalone" widgets, not with the extension methods. I can totally see not wanting to copy/paste the docs due to various reasons.
A possible way of circumventing this would be to use dartdoc Macros as described here.

What do you think about that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Optionally wrap Animate with RepaintBoundary
2 participants