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}) {
  return LayoutBuilder(
    builder: (BuildContext context, BoxConstraints constraints) {
      double delta = index - position;
      if (isStatic(delta, type, direction, snap, isScrolling)) {
        return child;
      }
      delta = delta.abs();
      double startOffset = animationAxis == Axis.horizontal
          ? ((itemWidth ?? constraints.maxWidth) * 0.105) *
              delta *
              this.startOffset
          : ((itemHeight ?? constraints.maxHeight) * 0.105) *
              delta *
              this.startOffset;
      return Transform.translate(
          offset: (animationAxis == Axis.horizontal
              ? Offset(startOffset, 0)
              : Offset(0, -startOffset)),
          child: child);
    },
  );
}