vertical method

Widget vertical(
  1. double aniValue,
  2. int index,
  3. double page,
  4. Widget child,
)

Implementation

Widget vertical(double aniValue, int index, double page, Widget child) {
  /// 0 - origin  1 - 0
  final angle = -originAngle * aniValue + originAngle;
  if (page >= index) {
    /// _pageController.page > index 向右滑动 划出下一页 下一页可见
    return LayoutBuilder(builder: (context, constraints) {
      final halfWide = constraints.maxHeight / 2 - fineTuning;
      final offset = -halfWide * aniValue + halfWide;
      return Transform(
        transform: Matrix4.identity()
          ..setEntry(3, 2, 0.001)
          ..translate(.0, offset, .0)
          ..rotateX(-angle),
        alignment: Alignment.center,
        child: child,
      );
    });
  } else {
    /// _pageController.page < index 向下滑动 划出上一页
    return LayoutBuilder(builder: (context, constraints) {
      final halfWide = constraints.maxHeight / 2 - fineTuning;
      final offset = -halfWide * aniValue + halfWide;
      return Transform(
        transform: Matrix4.identity()
          ..setEntry(3, 2, 0.001)
          ..translate(.0, -offset, .0)
          ..rotateX(angle),
        alignment: Alignment.center,
        child: child,
      );
    });
  }
}