build method

  1. @override
Widget build({
  1. required Animation<double> animation,
  2. required Widget child,
  3. Map<String, Object?> params = const {},
})
override

Builds the animated widget for the forward direction.

animation0.0 → 1.0 where 0.0 = invisible/start, 1.0 = visible/end. child — the widget being animated. params — optional configuration map (typed by each plugin).

Concrete subclasses must override this method.

Implementation

@override
Widget build({
  required Animation<double> animation,
  required Widget child,
  Map<String, Object?> params = const {},
}) {
  final from = (params['from'] as double?) ?? 0.0;
  final to = (params['to'] as double?) ?? 1.0;

  // Fast path: full 0→1 fade uses Flutter's built-in FadeTransition
  if (from == 0.0 && to == 1.0) {
    return FadeTransition(opacity: animation, child: child);
  }

  // Custom range fade
  return AnimatedBuilder(
    animation: animation,
    builder: (_, c) {
      final opacity = (from + (to - from) * animation.value).clamp(0.0, 1.0);
      return Opacity(opacity: opacity, child: c);
    },
    child: child,
  );
}