build method
Widget
build(
- BuildContext context,
- Widget child,
- AnimationController controller,
- EffectEntry entry,
override
Builds the widgets necessary to implement the effect, based on the provided AnimationController and EffectEntry.
Implementation
@override
Widget build(
BuildContext context,
Widget child,
AnimationController controller,
EffectEntry entry,
) {
// instead of setting up an animation, we can optimize a bit to calculate the callback time once:
double ratio = getEndRatio(controller, entry);
Widget endChild = builder(context, entry.owner.child);
// this could use toggleBuilder, but everything is pre-built, so this is simpler:
return AnimatedBuilder(
animation: controller,
builder: (_, __) => (controller.value < ratio) ? child : endChild,
);
}