@@ -567,4 +567,170 @@ void main() {
567567 final RenderBox box = tester.renderObject (find.byType (Drawer ));
568568 expect (box.size.width, equals (smallWidth));
569569 });
570+
571+ testWidgets ('Drawer default shape (ltr)' , (WidgetTester tester) async {
572+ await tester.pumpWidget (
573+ MaterialApp (
574+ theme: ThemeData (useMaterial3: true ),
575+ home: const Directionality (
576+ textDirection: TextDirection .ltr,
577+ child: Scaffold (
578+ drawer: Drawer (),
579+ endDrawer: Drawer (),
580+ ),
581+ ),
582+ ),
583+ );
584+
585+ final Finder drawerMaterial = find.descendant (
586+ of: find.byType (Drawer ),
587+ matching: find.byType (Material ),
588+ );
589+
590+ final ScaffoldState state = tester.firstState (find.byType (Scaffold ));
591+
592+ // Open the drawer.
593+ state.openDrawer ();
594+ await tester.pump ();
595+ await tester.pump (const Duration (seconds: 1 ));
596+
597+ // Test the drawer shape.
598+ Material material = tester.widget <Material >(drawerMaterial);
599+ expect (
600+ material.shape,
601+ const RoundedRectangleBorder (
602+ borderRadius: BorderRadius .only (
603+ topRight: Radius .circular (16.0 ),
604+ bottomRight: Radius .circular (16.0 ),
605+ ),
606+ ),
607+ );
608+
609+ // Close the opened drawer.
610+ await tester.tapAt (const Offset (750 , 300 ));
611+ await tester.pumpAndSettle ();
612+
613+ // Open the end drawer.
614+ state.openEndDrawer ();
615+ await tester.pump ();
616+ await tester.pump (const Duration (seconds: 1 ));
617+
618+ // Test the end drawer shape.
619+ material = tester.widget <Material >(drawerMaterial);
620+ expect (
621+ material.shape,
622+ const RoundedRectangleBorder (
623+ borderRadius: BorderRadius .only (
624+ topLeft: Radius .circular (16.0 ),
625+ bottomLeft: Radius .circular (16.0 ),
626+ ),
627+ ),
628+ );
629+ });
630+
631+ testWidgets ('Drawer default shape (rtl)' , (WidgetTester tester) async {
632+ await tester.pumpWidget (
633+ MaterialApp (
634+ theme: ThemeData (useMaterial3: true ),
635+ home: const Directionality (
636+ textDirection: TextDirection .rtl,
637+ child: Scaffold (
638+ drawer: Drawer (),
639+ endDrawer: Drawer (),
640+ ),
641+ ),
642+ ),
643+ );
644+
645+ final Finder drawerMaterial = find.descendant (
646+ of: find.byType (Drawer ),
647+ matching: find.byType (Material ),
648+ );
649+
650+ final ScaffoldState state = tester.firstState (find.byType (Scaffold ));
651+
652+ // Open the drawer.
653+ state.openDrawer ();
654+ await tester.pump ();
655+ await tester.pump (const Duration (seconds: 1 ));
656+
657+ // Test the drawer shape.
658+ Material material = tester.widget <Material >(drawerMaterial);
659+ expect (
660+ material.shape,
661+ const RoundedRectangleBorder (
662+ borderRadius: BorderRadius .only (
663+ topLeft: Radius .circular (16.0 ),
664+ bottomLeft: Radius .circular (16.0 ),
665+ ),
666+ ),
667+ );
668+
669+ // Close the opened drawer.
670+ await tester.tapAt (const Offset (750 , 300 ));
671+ await tester.pumpAndSettle ();
672+
673+ // Open the end drawer.
674+ state.openEndDrawer ();
675+ await tester.pump ();
676+ await tester.pump (const Duration (seconds: 1 ));
677+
678+ // Test the end drawer shape.
679+ material = tester.widget <Material >(drawerMaterial);
680+ expect (
681+ material.shape,
682+ const RoundedRectangleBorder (
683+ borderRadius: BorderRadius .only (
684+ topRight: Radius .circular (16.0 ),
685+ bottomRight: Radius .circular (16.0 ),
686+ ),
687+ ),
688+ );
689+ });
690+
691+ group ('Material 2' , () {
692+ // Tests that are only relevant for Material 2. Once ThemeData.useMaterial3
693+ // is turned on by default, these tests can be removed.
694+
695+ testWidgets ('Drawer default shape' , (WidgetTester tester) async {
696+ await tester.pumpWidget (
697+ MaterialApp (
698+ theme: ThemeData (useMaterial3: false ),
699+ home: const Scaffold (
700+ drawer: Drawer (),
701+ endDrawer: Drawer (),
702+ ),
703+ ),
704+ );
705+
706+ final Finder drawerMaterial = find.descendant (
707+ of: find.byType (Drawer ),
708+ matching: find.byType (Material ),
709+ );
710+
711+ final ScaffoldState state = tester.firstState (find.byType (Scaffold ));
712+
713+ // Open the drawer.
714+ state.openDrawer ();
715+ await tester.pump ();
716+ await tester.pump (const Duration (seconds: 1 ));
717+
718+ // Test the drawer shape.
719+ Material material = tester.widget <Material >(drawerMaterial);
720+ expect (material.shape, null );
721+
722+ // Close the opened drawer.
723+ await tester.tapAt (const Offset (750 , 300 ));
724+ await tester.pumpAndSettle ();
725+
726+ // Open the end drawer.
727+ state.openEndDrawer ();
728+ await tester.pump ();
729+ await tester.pump (const Duration (seconds: 1 ));
730+
731+ // Test the end drawer shape.
732+ material = tester.widget <Material >(drawerMaterial);
733+ expect (material.shape, null );
734+ });
735+ });
570736}
0 commit comments