build method

  1. @override
Widget build(
  1. BuildContext context,
  2. Widget child,
  3. AnimationController controller,
  4. 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,
) {
  // build an animation without a curve, so we get a linear 0-1 value back so we can determine start / end.
  Animation<double> animation = entry.buildAnimation(
    controller,
    curve: Curves.linear,
  );
  double prev = 0.0, begin = this.begin ?? 0.0, end = this.end ?? 1.0;
  animation.addListener(() {
    double value = animation.value;
    if (!clamp || value != prev) {
      callback(begin + (end - begin) * entry.curve.transform(value));
      prev = value;
    }
  });
  return child;
}