LCOV - code coverage report
Current view: top level - routes - zoom_page_route.dart (source / functions) Hit Total Coverage
Test: filtered.info Lines: 18 18 100.0 %
Date: 2022-01-21 22:05:42 Functions: 0 0 -

          Line data    Source code
       1             : import 'package:flutter/material.dart';
       2             : 
       3             : class ZoomPageRoute<T> extends PageRouteBuilder<T> {
       4           1 :   ZoomPageRoute({
       5             :     Curve transitionCurve = Curves.linearToEaseOut,
       6             :     Duration transitionDuration = const Duration(milliseconds: 500),
       7             :     required WidgetBuilder builder,
       8           1 :   }) : super(
       9             :           transitionDuration: transitionDuration,
      10           1 :           transitionsBuilder: createTranstionBuilder(transitionCurve),
      11           1 :           pageBuilder: (context, _, __) {
      12             :             return builder(context);
      13             :           },
      14             :         );
      15             : 
      16           1 :   static RouteTransitionsBuilder createTranstionBuilder(Curve curve) {
      17           1 :     return (context, animationIn, animationOut, child) {
      18           1 :       final reverseCurve = curve.flipped;
      19             : 
      20           1 :       final opacityAnimationIn = CurvedAnimation(
      21             :         parent: animationIn,
      22             :         curve: curve,
      23             :         reverseCurve: reverseCurve,
      24             :       );
      25           1 :       final opacityAnimationOut = CurvedAnimation(
      26           2 :         parent: animationOut.drive(Tween(begin: 1, end: 0)),
      27             : 
      28             :         // Note: in practice, this curve is flipped because of how the
      29             :         //   value is used within the transition.
      30             :         //
      31             :         // If `curve: curve` is set, the page will lose opacity very
      32             :         //   slowly at the start and then drop off sharp near the end
      33             :         //   (essentially the same as `curve.flipped`,
      34             :         //   i.e., `reverseCurve`).
      35             :         // If `curve: reverseCurve` is set, the animation will exhibit
      36             :         //   the behavior expected of `curve` (unflipped), and the
      37             :         //   opacity will start with a fast dropoff and then slowly
      38             :         //   settles.
      39             :         curve: reverseCurve,
      40             :         reverseCurve: curve,
      41             :       );
      42           1 :       final scaleAnimationIn = CurvedAnimation(
      43             :         parent: animationIn,
      44             :         curve: curve,
      45             :         reverseCurve: reverseCurve,
      46           2 :       ).drive<double>(Tween(begin: 0.8, end: 1));
      47           1 :       final scaleAnimationOut = CurvedAnimation(
      48             :         parent: animationOut,
      49             :         curve: curve,
      50             :         reverseCurve: reverseCurve,
      51           2 :       ).drive<double>(Tween(begin: 1, end: 1.2));
      52             : 
      53           1 :       return FadeTransition(
      54             :         opacity: opacityAnimationIn,
      55           1 :         child: FadeTransition(
      56             :           opacity: opacityAnimationOut,
      57           1 :           child: ScaleTransition(
      58             :             scale: scaleAnimationIn,
      59           1 :             child: ScaleTransition(
      60             :               scale: scaleAnimationOut,
      61             :               child: child,
      62             :             ),
      63             :           ),
      64             :         ),
      65             :       );
      66             :     };
      67             :   }
      68             : }

Generated by: LCOV version 1.15