@@ -519,4 +519,111 @@ void main() {
519
519
expect (find.text ('push' ), findsOneWidget);
520
520
expect (find.text ('page b' ), findsNothing);
521
521
}, variant: TargetPlatformVariant .all ());
522
+
523
+ testWidgets ('ZoomPageTransitionsBuilder uses theme color during transition effects' , (WidgetTester tester) async {
524
+ // Color that is being tested for presence.
525
+ const Color themeTestSurfaceColor = Color .fromARGB (255 , 195 , 255 , 0 );
526
+
527
+ final Map <String , WidgetBuilder > routes = < String , WidgetBuilder > {
528
+ '/' : (BuildContext context) => Material (
529
+ child: Scaffold (
530
+ appBar: AppBar (
531
+ title: const Text ('Home Page' ),
532
+ ),
533
+ body: Center (
534
+ child: Column (
535
+ mainAxisAlignment: MainAxisAlignment .center,
536
+ children: < Widget > [
537
+ ElevatedButton (
538
+ onPressed: () {
539
+ Navigator .pushNamed (context, '/scaffolded' );
540
+ },
541
+ child: const Text ('Route with scaffold!' ),
542
+ ),
543
+ ElevatedButton (
544
+ onPressed: () {
545
+ Navigator .pushNamed (context, '/not-scaffolded' );
546
+ },
547
+ child: const Text ('Route with NO scaffold!' ),
548
+ ),
549
+ ],
550
+ ),
551
+ ),
552
+ ),
553
+ ),
554
+ '/scaffolded' : (BuildContext context) => Material (
555
+ child: Scaffold (
556
+ appBar: AppBar (
557
+ title: const Text ('Scaffolded Page' ),
558
+ ),
559
+ body: Center (
560
+ child: ElevatedButton (
561
+ onPressed: () {
562
+ Navigator .pop (context);
563
+ },
564
+ child: const Text ('Back to home route...' ),
565
+ ),
566
+ ),
567
+ ),
568
+ ),
569
+ '/not-scaffolded' : (BuildContext context) => Material (
570
+ child: Center (
571
+ child: ElevatedButton (
572
+ onPressed: () {
573
+ Navigator .pop (context);
574
+ },
575
+ child: const Text ('Back to home route...' ),
576
+ ),
577
+ ),
578
+ ),
579
+ };
580
+
581
+ await tester.pumpWidget (
582
+ MaterialApp (
583
+ theme: ThemeData (
584
+ colorScheme: ColorScheme .fromSeed (seedColor: Colors .blue, surface: themeTestSurfaceColor),
585
+ pageTransitionsTheme: PageTransitionsTheme (
586
+ builders: < TargetPlatform , PageTransitionsBuilder > {
587
+ // Force all platforms to use ZoomPageTransitionsBuilder to test each one.
588
+ for (final TargetPlatform platform in TargetPlatform .values) platform: const ZoomPageTransitionsBuilder (),
589
+ },
590
+ ),
591
+ ),
592
+ routes: routes,
593
+ ),
594
+ );
595
+
596
+ // Go to scaffolded page.
597
+ await tester.tap (find.text ('Route with scaffold!' ));
598
+
599
+ // Pump till animation is half-way through.
600
+ await tester.pump ();
601
+ await tester.pump (const Duration (milliseconds: 75 ));
602
+
603
+ // Verify that the render box is painting the right color for scaffolded pages.
604
+ final RenderBox scaffoldedRenderBox = tester.firstRenderObject <RenderBox >(find.byType (MaterialApp ));
605
+ // Expect the color to be at exactly 12.2% opacity at this time.
606
+ expect (scaffoldedRenderBox, paints..rect (color: themeTestSurfaceColor.withOpacity (0.122 )));
607
+
608
+ await tester.pumpAndSettle ();
609
+
610
+ // Go back home and then go to non-scaffolded page.
611
+ await tester.tap (find.text ('Back to home route...' ));
612
+ await tester.pumpAndSettle ();
613
+ await tester.tap (find.text ('Route with NO scaffold!' ));
614
+
615
+ // Pump till animation is half-way through.
616
+ await tester.pump ();
617
+ await tester.pump (const Duration (milliseconds: 125 ));
618
+
619
+ // Verify that the render box is painting the right color for non-scaffolded pages.
620
+ final RenderBox nonScaffoldedRenderBox = tester.firstRenderObject <RenderBox >(find.byType (MaterialApp ));
621
+ // Expect the color to be at exactly 59.6% opacity at this time.
622
+ expect (nonScaffoldedRenderBox, paints..rect (color: themeTestSurfaceColor.withOpacity (0.596 )));
623
+
624
+ await tester.pumpAndSettle ();
625
+
626
+ // Verify that the transition successfully completed.
627
+ expect (find.text ('Back to home route...' ), findsOneWidget);
628
+ }, variant: TargetPlatformVariant .all ());
522
629
}
0 commit comments