getOptimizedBuilder<U> method
AnimatedBuilder
getOptimizedBuilder<U>({
- required ValueListenable<
U> animation, - Widget? child,
- required TransitionBuilder builder,
Returns an optimized AnimatedBuilder that doesn't rebuild if the value hasn't changed.
Implementation
AnimatedBuilder getOptimizedBuilder<U>({
required ValueListenable<U> animation,
Widget? child,
required TransitionBuilder builder,
}) {
U? value;
Widget? widget;
return AnimatedBuilder(
animation: animation,
builder: (ctx, _) {
if (animation.value != value) widget = null;
value = animation.value;
return widget = widget ?? builder(ctx, child);
},
);
}