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 fromR = (params['fromRadius'] as double?) ?? 8.0;
  final toR = (params['toRadius'] as double?) ?? 32.0;
  final fromColor =
      (params['fromColor'] as Color?) ?? const Color(0xFF1976D2);
  final toColor =
      (params['toColor'] as Color?) ?? const Color(0xFF42A5F5);
  final clipContent = (params['clip'] as bool?) ?? true;

  return AnimatedBuilder(
    animation: animation,
    builder: (_, c) {
      final t = animation.value;
      final radius = fromR + (toR - fromR) * t;
      final color = Color.lerp(fromColor, toColor, t)!;
      final borderRadius = BorderRadius.circular(radius);
      Widget result = DecoratedBox(
        decoration: BoxDecoration(color: color, borderRadius: borderRadius),
        child: c,
      );
      if (clipContent) {
        result = ClipRRect(borderRadius: borderRadius, child: result);
      }
      return result;
    },
    child: child,
  );
}