buildEffect method

  1. @override
Widget buildEffect({
  1. required Widget child,
  2. required int index,
  3. required double position,
  4. double? itemWidth,
  5. double? itemHeight,
  6. bool? isScrolling,
  7. required AnimationScrollDirection direction,
})
override

Implementation

@override
Widget buildEffect(
    {required Widget child,
    required int index,
    required double position,
    double? itemWidth,
    double? itemHeight,
    bool? isScrolling,
    required AnimationScrollDirection direction}) {
  double delta = index - position;
  if (isStatic(delta, type, direction, snap, isScrolling)) {
    return child;
  }
  delta = delta.abs();
  double opacity = 1.0 - delta * this.opacity;
  return Opacity(
    opacity: opacity < 0
        ? 0
        : opacity > 1
            ? 1
            : opacity,
    child: child,
  );
}