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