getToggleBuilder method
AnimatedBuilder
getToggleBuilder({
- required ValueListenable<
double> animation, - required Widget child,
- required bool toggle(),
- required ToggleEffectBuilder builder,
Returns an AnimatedBuilder that rebuilds when the
boolean value returned by the toggle
function changes.
Implementation
AnimatedBuilder getToggleBuilder({
required ValueListenable<double> animation,
required Widget child,
required bool Function() toggle,
required ToggleEffectBuilder builder,
}) {
ValueNotifier<bool> notifier = ValueNotifier<bool>(toggle());
animation.addListener(() => notifier.value = toggle());
return AnimatedBuilder(
animation: notifier,
builder: (ctx, _) => builder(ctx, notifier.value, child),
);
}