@@ -9,8 +9,7 @@ import 'colors.dart';
9
9
import 'theme.dart' ;
10
10
11
11
// Slides the page upwards and fades it in, starting from 1/4 screen
12
- // below the top. The transition is intended to match the default for
13
- // Android O.
12
+ // below the top.
14
13
class _FadeUpwardsPageTransition extends StatelessWidget {
15
14
_FadeUpwardsPageTransition ({
16
15
Key ? key,
@@ -147,7 +146,7 @@ class _OpenUpwardsPageTransition extends StatelessWidget {
147
146
}
148
147
149
148
// Zooms and fades a new page in, zooming out the previous page. This transition
150
- // is designed to match the Android Q activity transition.
149
+ // is designed to match the Android 10 activity transition.
151
150
class _ZoomPageTransition extends StatelessWidget {
152
151
/// Creates a [_ZoomPageTransition] .
153
152
///
@@ -292,16 +291,16 @@ class _ZoomEnterTransition extends StatelessWidget {
292
291
@override
293
292
Widget build (BuildContext context) {
294
293
double opacity = 0 ;
295
- // The transition's scrim opacity only increases on the forward transition.
296
- // In the reverse transition, the opacity should always be 0.0.
294
+ // The transition's scrim opacity only increases on the forward transition. In the reverse
295
+ // transition, the opacity should always be 0.0.
297
296
//
298
- // Therefore, we need to only apply the scrim opacity animation when
299
- // the transition is running forwards.
297
+ // Therefore, we need to only apply the scrim opacity animation when the transition
298
+ // is running forwards.
300
299
//
301
- // The reason that we check that the animation's status is not `completed`
302
- // instead of checking that it is `forward` is that this allows
303
- // the interrupted reversal of the forward transition to smoothly fade
304
- // the scrim away. This prevents a disjointed removal of the scrim.
300
+ // The reason that we check that the animation's status is not `completed` instead
301
+ // of checking that it is `forward` is that this allows the interrupted reversal of the
302
+ // forward transition to smoothly fade the scrim away. This prevents a disjointed
303
+ // removal of the scrim.
305
304
if (! reverse && animation.status != AnimationStatus .completed) {
306
305
opacity = _scrimOpacityTween.evaluate (animation)! ;
307
306
}
@@ -318,14 +317,17 @@ class _ZoomEnterTransition extends StatelessWidget {
318
317
return AnimatedBuilder (
319
318
animation: animation,
320
319
builder: (BuildContext context, Widget ? child) {
321
- return ColoredBox (
320
+ return Container (
322
321
color: Colors .black.withOpacity (opacity),
323
322
child: child,
324
323
);
325
324
},
326
325
child: FadeTransition (
327
326
opacity: fadeTransition,
328
- child: ScaleTransition (scale: scaleTransition, child: child),
327
+ child: ScaleTransition (
328
+ scale: scaleTransition,
329
+ child: child,
330
+ ),
329
331
),
330
332
);
331
333
}
@@ -372,7 +374,10 @@ class _ZoomExitTransition extends StatelessWidget {
372
374
373
375
return FadeTransition (
374
376
opacity: fadeTransition,
375
- child: ScaleTransition (scale: scaleTransition, child: child),
377
+ child: ScaleTransition (
378
+ scale: scaleTransition,
379
+ child: child,
380
+ ),
376
381
);
377
382
}
378
383
}
@@ -386,12 +391,11 @@ class _ZoomExitTransition extends StatelessWidget {
386
391
///
387
392
/// See also:
388
393
///
389
- /// * [FadeUpwardsPageTransitionsBuilder] , which defines a page transition
390
- /// that's similar to the one provided by Android O.
394
+ /// * [FadeUpwardsPageTransitionsBuilder] , which defines a default page transition.
391
395
/// * [OpenUpwardsPageTransitionsBuilder] , which defines a page transition
392
396
/// that's similar to the one provided by Android P.
393
- /// * [ZoomPageTransitionsBuilder] , which defines the default page transition
394
- /// that's similar to the one provided in Android Q .
397
+ /// * [ZoomPageTransitionsBuilder] , which defines a page transition similar
398
+ /// to the one provided in Android 10 .
395
399
/// * [CupertinoPageTransitionsBuilder] , which defines a horizontal page
396
400
/// transition that matches native iOS page transitions.
397
401
abstract class PageTransitionsBuilder {
@@ -415,19 +419,18 @@ abstract class PageTransitionsBuilder {
415
419
);
416
420
}
417
421
418
- /// Used by [PageTransitionsTheme] to define a vertically fading
419
- /// [MaterialPageRoute] page transition animation that looks like
420
- /// the default page transition used on Android O.
422
+ /// Used by [PageTransitionsTheme] to define a default [MaterialPageRoute] page
423
+ /// transition animation.
421
424
///
422
- /// The animation fades the new page in while translating it upwards,
425
+ /// The default animation fades the new page in while translating it upwards,
423
426
/// starting from about 25% below the top of the screen.
424
427
///
425
428
/// See also:
426
429
///
427
430
/// * [OpenUpwardsPageTransitionsBuilder] , which defines a page transition
428
431
/// that's similar to the one provided by Android P.
429
- /// * [ZoomPageTransitionsBuilder] , which defines the default page transition
430
- /// that's similar to the one provided in Android Q .
432
+ /// * [ZoomPageTransitionsBuilder] , which defines a page transition similar
433
+ /// to the one provided in Android 10 .
431
434
/// * [CupertinoPageTransitionsBuilder] , which defines a horizontal page
432
435
/// transition that matches native iOS page transitions.
433
436
class FadeUpwardsPageTransitionsBuilder extends PageTransitionsBuilder {
@@ -452,10 +455,9 @@ class FadeUpwardsPageTransitionsBuilder extends PageTransitionsBuilder {
452
455
///
453
456
/// See also:
454
457
///
455
- /// * [FadeUpwardsPageTransitionsBuilder] , which defines a page transition
456
- /// that's similar to the one provided by Android O.
457
- /// * [ZoomPageTransitionsBuilder] , which defines the default page transition
458
- /// that's similar to the one provided in Android Q.
458
+ /// * [FadeUpwardsPageTransitionsBuilder] , which defines a default page transition.
459
+ /// * [ZoomPageTransitionsBuilder] , which defines a page transition similar
460
+ /// to the one provided in Android 10.
459
461
/// * [CupertinoPageTransitionsBuilder] , which defines a horizontal page
460
462
/// transition that matches native iOS page transitions.
461
463
class OpenUpwardsPageTransitionsBuilder extends PageTransitionsBuilder {
@@ -481,19 +483,18 @@ class OpenUpwardsPageTransitionsBuilder extends PageTransitionsBuilder {
481
483
482
484
/// Used by [PageTransitionsTheme] to define a zooming [MaterialPageRoute] page
483
485
/// transition animation that looks like the default page transition used on
484
- /// Android Q .
486
+ /// Android 10 .
485
487
///
486
488
/// See also:
487
489
///
488
- /// * [FadeUpwardsPageTransitionsBuilder] , which defines a page transition
489
- /// that's similar to the one provided by Android O.
490
+ /// * [FadeUpwardsPageTransitionsBuilder] , which defines a default page transition.
490
491
/// * [OpenUpwardsPageTransitionsBuilder] , which defines a page transition
491
- /// that's similar to the one provided by Android P.
492
+ /// similar to the one provided by Android P.
492
493
/// * [CupertinoPageTransitionsBuilder] , which defines a horizontal page
493
494
/// transition that matches native iOS page transitions.
494
495
class ZoomPageTransitionsBuilder extends PageTransitionsBuilder {
495
496
/// Constructs a page transition animation that matches the transition used on
496
- /// Android Q .
497
+ /// Android 10 .
497
498
const ZoomPageTransitionsBuilder ();
498
499
499
500
@override
@@ -517,12 +518,11 @@ class ZoomPageTransitionsBuilder extends PageTransitionsBuilder {
517
518
///
518
519
/// See also:
519
520
///
520
- /// * [FadeUpwardsPageTransitionsBuilder] , which defines a page transition
521
- /// that's similar to the one provided by Android O.
521
+ /// * [FadeUpwardsPageTransitionsBuilder] , which defines a default page transition.
522
522
/// * [OpenUpwardsPageTransitionsBuilder] , which defines a page transition
523
523
/// that's similar to the one provided by Android P.
524
- /// * [ZoomPageTransitionsBuilder] , which defines the default page transition
525
- /// that's similar to the one provided in Android Q .
524
+ /// * [ZoomPageTransitionsBuilder] , which defines a page transition similar
525
+ /// to the one provided in Android 10 .
526
526
class CupertinoPageTransitionsBuilder extends PageTransitionsBuilder {
527
527
/// Constructs a page transition animation that matches the iOS transition.
528
528
const CupertinoPageTransitionsBuilder ();
@@ -553,35 +553,34 @@ class CupertinoPageTransitionsBuilder extends PageTransitionsBuilder {
553
553
///
554
554
/// * [ThemeData.pageTransitionsTheme] , which defines the default page
555
555
/// transitions for the overall theme.
556
- /// * [FadeUpwardsPageTransitionsBuilder] , which defines a page transition
557
- /// that's similar to the one provided by Android O.
556
+ /// * [FadeUpwardsPageTransitionsBuilder] , which defines a default page transition.
558
557
/// * [OpenUpwardsPageTransitionsBuilder] , which defines a page transition
559
558
/// that's similar to the one provided by Android P.
560
- /// * [ZoomPageTransitionsBuilder] , which defines the default page transition
561
- /// that's similar to the one provided by Android Q.
562
559
/// * [CupertinoPageTransitionsBuilder] , which defines a horizontal page
563
560
/// transition that matches native iOS page transitions.
564
561
@immutable
565
562
class PageTransitionsTheme with Diagnosticable {
566
563
/// Constructs an object that selects a transition based on the platform.
567
564
///
568
- /// By default the list of builders is: [ZoomPageTransitionsBuilder ]
565
+ /// By default the list of builders is: [FadeUpwardsPageTransitionsBuilder ]
569
566
/// for [TargetPlatform.android] , and [CupertinoPageTransitionsBuilder] for
570
567
/// [TargetPlatform.iOS] and [TargetPlatform.macOS] .
571
568
const PageTransitionsTheme ({ Map <TargetPlatform , PageTransitionsBuilder > builders = _defaultBuilders }) : _builders = builders;
572
569
573
570
static const Map <TargetPlatform , PageTransitionsBuilder > _defaultBuilders = < TargetPlatform , PageTransitionsBuilder > {
574
- TargetPlatform .android: ZoomPageTransitionsBuilder (),
571
+ TargetPlatform .android: FadeUpwardsPageTransitionsBuilder (),
575
572
TargetPlatform .iOS: CupertinoPageTransitionsBuilder (),
573
+ TargetPlatform .linux: FadeUpwardsPageTransitionsBuilder (),
576
574
TargetPlatform .macOS: CupertinoPageTransitionsBuilder (),
575
+ TargetPlatform .windows: FadeUpwardsPageTransitionsBuilder (),
577
576
};
578
577
579
578
/// The [PageTransitionsBuilder] s supported by this theme.
580
579
Map <TargetPlatform , PageTransitionsBuilder > get builders => _builders;
581
580
final Map <TargetPlatform , PageTransitionsBuilder > _builders;
582
581
583
582
/// Delegates to the builder for the current [ThemeData.platform]
584
- /// or [ZoomPageTransitionsBuilder ] .
583
+ /// or [FadeUpwardsPageTransitionsBuilder ] .
585
584
///
586
585
/// [MaterialPageRoute.buildTransitions] delegates to this method.
587
586
Widget buildTransitions <T >(
@@ -597,7 +596,7 @@ class PageTransitionsTheme with Diagnosticable {
597
596
platform = TargetPlatform .iOS;
598
597
599
598
final PageTransitionsBuilder matchingBuilder =
600
- builders[platform] ?? const ZoomPageTransitionsBuilder ();
599
+ builders[platform] ?? const FadeUpwardsPageTransitionsBuilder ();
601
600
return matchingBuilder.buildTransitions <T >(route, context, animation, secondaryAnimation, child);
602
601
}
603
602
0 commit comments