show method

List<Widget> show({
  1. Duration delay = Duration.zero,
  2. Duration increment = const Duration(milliseconds: 100),
  3. Duration duration = const Duration(seconds: 1, milliseconds: 500),
  4. Curve? curve,
  5. double begin = 2,
  6. double end = 0,
  7. int limit = 8,
})

Animate a list of widgets with a default slide and fade animation.

  • delay is the delay before the first animation starts.
  • increment is the delay between each animation.
  • duration is the duration of the animation.
  • curve is the curve of the animation.
  • begin is the starting position of the animation.
  • end is the ending position of the animation.
  • limit is the maximum number of widgets to animate (0 for all).

Implementation

List<Widget> show({
  Duration delay = Duration.zero,
  Duration increment = const Duration(milliseconds: 100),
  Duration duration = const Duration(seconds: 1, milliseconds: 500),
  Curve? curve,
  double begin = 2,
  double end = 0,
  int limit = 8,
}) {
  assert(limit >= 0, 'Limit must be positive');

  curve ??= Sprung.custom(damping: 19);

  var animated = 0;

  final widgets = <Widget>[];

  for (var i = 0; i < length; i++) {
    // Don't animate spacer widgets
    if (this[i] is SizedBox && (this[i] as SizedBox).child == null) {
      widgets.add(this[i]);
      continue;
    }

    if (limit > 0 && animated >= limit) {
      widgets.add(this[i]);
      continue;
    }

    widgets.add(
      this[i]
          .animate()
          .slideY(
            begin: begin,
            end: end,
            curve: curve,
            duration: duration,
            delay: delay + increment * i,
          )
          .fadeIn(
            curve: curve,
            duration: duration,
            delay: delay + increment * i,
          ),
    );

    animated++;
  }

  return widgets;
}