transform method

  1. @override
Widget transform(
  1. BuildContext context,
  2. Widget page,
  3. int index,
  4. int? currentPage,
  5. double pageDelta,
  6. int itemCount,
)
override

Implementation

@override
Widget transform(BuildContext context, Widget page, int index, int? currentPage, double pageDelta, int itemCount) {
  final double width = MediaQuery.of(context).size.width;
  if (index == currentPage! + 1 && pageDelta > 0.5) {
    return Transform(
      alignment: Alignment.center,
      child: page,
      transform: Matrix4.identity()
        ..setEntry(3, 2, perspectiveScale)
        ..rotateY(math.pi * (pageDelta - 1))
        ..leftTranslate(-width * (1 - pageDelta)),
    );
  } else if (index == currentPage && pageDelta <= 0.5) {
    return Transform(
      alignment: Alignment.center,
      child: page,
      transform: Matrix4.identity()
        ..setEntry(3, 2, perspectiveScale)
        ..rotateY(math.pi * pageDelta)
        ..leftTranslate(width * pageDelta),
    );
  } else if (pageDelta == 0) {
    return page;
  } else {
    return Container();
  }
}