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 factor = (params['factor'] as double?) ?? 0.5;
  final distance = (params['distance'] as double?) ?? 200.0;
  final axis = (params['direction'] as Axis?) ?? Axis.vertical;

  return AnimatedBuilder(
    animation: animation,
    builder: (_, c) {
      final delta = (1.0 - animation.value) * distance * factor;
      final offset = axis == Axis.vertical
          ? Offset(0.0, delta)
          : Offset(delta, 0.0);
      return Transform.translate(offset: offset, child: c);
    },
    child: child,
  );
}