-
Notifications
You must be signed in to change notification settings - Fork 86
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -116,6 +116,7 @@ class Animate extends StatefulWidget with AnimateManager<Animate> { | |
this.controller, | ||
this.adapter, | ||
this.target, | ||
this.useRepaintBoundary = false, | ||
}) : super(key: key) { | ||
_entries = []; | ||
if (effects != null) addEffects(effects); | ||
|
@@ -176,6 +177,9 @@ class Animate extends StatefulWidget with AnimateManager<Animate> { | |
/// ``` | ||
final double? target; | ||
|
||
// TODO: add documentation | ||
final bool useRepaintBoundary; | ||
|
||
late final List<EffectEntry> _entries; | ||
Duration _duration = Duration.zero; | ||
EffectEntry? _lastEntry; | ||
|
@@ -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); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
return returnWidget; | ||
} | ||
} | ||
|
||
|
@@ -336,6 +342,7 @@ extension AnimateWidgetExtensions on Widget { | |
AnimationController? controller, | ||
Adapter? adapter, | ||
double? target, | ||
bool? useRepaintBoundary, | ||
}) => | ||
Animate( | ||
key: key, | ||
|
@@ -346,6 +353,7 @@ extension AnimateWidgetExtensions on Widget { | |
controller: controller, | ||
adapter: adapter, | ||
target: target, | ||
useRepaintBoundary: useRepaintBoundary ?? false, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Really good point, pulled it out of the constructors! |
||
child: this, | ||
); | ||
} | ||
|
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 :)