buildEffect method
Widget
buildEffect({
- required Widget child,
- required int index,
- required double position,
- double? itemWidth,
- double? itemHeight,
- bool? isScrolling,
- 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);
},
);
}