Advertisement
harmonyV

Animating switching PageViews

Jul 22nd, 2024
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 2.36 KB | None | 0 0
  1. return AnimatedCrossFade(
  2.                     duration: const Duration(seconds: 1),
  3.                     firstChild: ConstrainedBox(
  4.                       constraints:
  5.                           BoxConstraints(maxHeight: habitTileConst * 5),
  6.                       child: PageView(
  7.                         controller: _listPageController,
  8.                         children: habitTileListPages,
  9.                         onPageChanged: (value) {
  10.                           habitDataBase.setSelectionList(
  11.                               Selection.values.elementAt(value));
  12.                         },
  13.                       ),
  14.                     ).animate(
  15.                       onComplete: (controller) {
  16.                         debugPrint(
  17.                             "ANIMATION COMPLETED: ${controller.isCompleted}");
  18.                       },
  19.                     ).scale(
  20.                       duration: const Duration(
  21.                         seconds: 1,
  22.                         microseconds: 500,
  23.                       ),
  24.                       begin: const Offset(0, 0),
  25.                       curve: Curves.easeOutBack,
  26.                     ),
  27.                     secondChild: ConstrainedBox(
  28.                       constraints:
  29.                           BoxConstraints(maxHeight: habitTileConst * 5),
  30.                       child: PageView(
  31.                         controller: _gridPageController,
  32.                         children: habitTileGridPages,
  33.                         onPageChanged: (value) {
  34.                           habitDataBase.setSelectionList(
  35.                               Selection.values.elementAt(value));
  36.                         },
  37.                       ),
  38.                     ).animate(
  39.                       onComplete: (controller) {
  40.                         debugPrint(
  41.                             "ANIMATION COMPLETED: ${controller.isCompleted}");
  42.                       },
  43.                     ).scale(
  44.                       duration: const Duration(
  45.                         seconds: 1,
  46.                         microseconds: 500,
  47.                       ),
  48.                       begin: const Offset(0, 0),
  49.                       curve: Curves.easeOutBack,
  50.                     ),
  51.                     crossFadeState: gridView
  52.                         ? CrossFadeState.showSecond
  53.                         : CrossFadeState.showFirst,
  54.                   );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement