Line data Source code
1 : import 'package:flutter/material.dart';
2 :
3 1 : Widget _defaultTransitionsBuilder(
4 : BuildContext context,
5 : Animation<double> animation,
6 : Animation<double> secondaryAnimation,
7 : Widget child) {
8 : return child;
9 : }
10 :
11 : class CustomPageRouteBuilder<T> extends PageRoute<T> {
12 : /// Creates a route that delegates to builder callbacks.
13 : ///
14 : /// The [pageBuilder], [transitionsBuilder], [opaque], [barrierDismissible],
15 : /// and [maintainState] arguments must not be null.
16 1 : CustomPageRouteBuilder({
17 : super.settings,
18 : required this.pageBuilder,
19 : this.transitionsBuilder = _defaultTransitionsBuilder,
20 : this.transitionDuration = const Duration(milliseconds: 300),
21 : this.opaque = true,
22 : this.barrierDismissible = false,
23 : this.barrierColor,
24 : this.barrierLabel,
25 : this.maintainState = true,
26 1 : }) : super(fullscreenDialog: false);
27 :
28 : /// Used build the route's primary contents.
29 : ///
30 : /// See [ModalRoute.buildPage] for complete definition of the parameters.
31 : final RoutePageBuilder pageBuilder;
32 :
33 : /// Used to build the route's transitions.
34 : ///
35 : /// See [ModalRoute.buildTransitions] for complete definition of the parameters.
36 : final RouteTransitionsBuilder transitionsBuilder;
37 :
38 : @override
39 : final Duration transitionDuration;
40 :
41 : @override
42 : final bool opaque;
43 :
44 : @override
45 : final bool barrierDismissible;
46 :
47 : @override
48 : final Color? barrierColor;
49 :
50 : @override
51 : final String? barrierLabel;
52 :
53 : @override
54 : final bool maintainState;
55 :
56 1 : @override
57 : Widget buildPage(BuildContext context, Animation<double> animation,
58 : Animation<double> secondaryAnimation) {
59 2 : return pageBuilder(context, animation, secondaryAnimation);
60 : }
61 :
62 1 : @override
63 : Widget buildTransitions(BuildContext context, Animation<double> animation,
64 : Animation<double> secondaryAnimation, Widget child) {
65 2 : return transitionsBuilder(context, animation, secondaryAnimation, child);
66 : }
67 : }
|