@@ -1245,23 +1245,7 @@ final Animatable<double> _dialogScaleTween = Tween<double>(begin: 1.3, end: 1.0)
1245
1245
.chain (CurveTween (curve: Curves .linearToEaseOut));
1246
1246
1247
1247
Widget _buildCupertinoDialogTransitions (BuildContext context, Animation <double > animation, Animation <double > secondaryAnimation, Widget child) {
1248
- final CurvedAnimation fadeAnimation = CurvedAnimation (
1249
- parent: animation,
1250
- curve: Curves .easeInOut,
1251
- );
1252
- if (animation.status == AnimationStatus .reverse) {
1253
- return FadeTransition (
1254
- opacity: fadeAnimation,
1255
- child: child,
1256
- );
1257
- }
1258
- return FadeTransition (
1259
- opacity: fadeAnimation,
1260
- child: ScaleTransition (
1261
- scale: animation.drive (_dialogScaleTween),
1262
- child: child,
1263
- ),
1264
- );
1248
+ return child;
1265
1249
}
1266
1250
1267
1251
/// Displays an iOS-style dialog above the current contents of the app, with
@@ -1388,14 +1372,58 @@ class CupertinoDialogRoute<T> extends RawDialogRoute<T> {
1388
1372
String ? barrierLabel,
1389
1373
// This transition duration was eyeballed comparing with iOS
1390
1374
super .transitionDuration = const Duration (milliseconds: 250 ),
1391
- super .transitionBuilder = _buildCupertinoDialogTransitions ,
1375
+ this .transitionBuilder,
1392
1376
super .settings,
1393
1377
super .anchorPoint,
1394
1378
}) : super (
1395
1379
pageBuilder: (BuildContext context, Animation <double > animation, Animation <double > secondaryAnimation) {
1396
1380
return builder (context);
1397
1381
},
1382
+ transitionBuilder: transitionBuilder ?? _buildCupertinoDialogTransitions,
1398
1383
barrierLabel: barrierLabel ?? CupertinoLocalizations .of (context).modalBarrierDismissLabel,
1399
1384
barrierColor: barrierColor ?? CupertinoDynamicColor .resolve (kCupertinoModalBarrierColor, context),
1400
1385
);
1386
+
1387
+ /// Custom transition builder
1388
+ RouteTransitionsBuilder ? transitionBuilder;
1389
+
1390
+ CurvedAnimation ? _fadeAnimation;
1391
+
1392
+ @override
1393
+ Widget buildTransitions (BuildContext context, Animation <double > animation, Animation <double > secondaryAnimation, Widget child) {
1394
+
1395
+ if (transitionBuilder != null ) {
1396
+ return super .buildTransitions (context, animation, secondaryAnimation, child);
1397
+ }
1398
+
1399
+ if (_fadeAnimation? .parent != animation) {
1400
+ _fadeAnimation? .dispose ();
1401
+ _fadeAnimation = CurvedAnimation (
1402
+ parent: animation,
1403
+ curve: Curves .easeInOut,
1404
+ );
1405
+ }
1406
+
1407
+ final CurvedAnimation fadeAnimation = _fadeAnimation! ;
1408
+
1409
+ if (animation.status == AnimationStatus .reverse) {
1410
+ return FadeTransition (
1411
+ opacity: fadeAnimation,
1412
+ child: super .buildTransitions (context, animation, secondaryAnimation, child),
1413
+ );
1414
+ }
1415
+ return FadeTransition (
1416
+ opacity: fadeAnimation,
1417
+ child: ScaleTransition (
1418
+ scale: animation.drive (_dialogScaleTween),
1419
+ child: super .buildTransitions (context, animation, secondaryAnimation, child),
1420
+ ),
1421
+ );
1422
+ }
1423
+
1424
+ @override
1425
+ void dispose () {
1426
+ _fadeAnimation? .dispose ();
1427
+ super .dispose ();
1428
+ }
1401
1429
}
0 commit comments