@@ -8,6 +8,8 @@ void main() {
88 test ('Verify that a tap dismisses a modal BottomSheet' , () {
99 testWidgets ((WidgetTester tester) {
1010 BuildContext context;
11+ bool showBottomSheetThenCalled = false ;
12+
1113 tester.pumpWidget (new MaterialApp (
1214 routes: < String , RouteBuilder > {
1315 '/' : (RouteArguments args) {
@@ -20,7 +22,10 @@ void main() {
2022 tester.pump ();
2123 expect (tester.findText ('BottomSheet' ), isNull);
2224
23- showModalBottomSheet (context: context, child: new Text ('BottomSheet' ));
25+ showModalBottomSheet (context: context, child: new Text ('BottomSheet' )).then ((_) {
26+ showBottomSheetThenCalled = true ;
27+ });
28+
2429 tester.pump (); // bottom sheet show animation starts
2530 tester.pump (new Duration (seconds: 1 )); // animation done
2631 expect (tester.findText ('BottomSheet' ), isNotNull);
@@ -29,7 +34,8 @@ void main() {
2934 tester.tap (tester.findText ('BottomSheet' ));
3035 tester.pump (); // bottom sheet dismiss animation starts
3136 tester.pump (new Duration (seconds: 1 )); // animation done
32- tester.pump (new Duration (seconds: 2 )); // rebuild frame
37+ tester.pump (new Duration (seconds: 1 )); // rebuild frame
38+ expect (showBottomSheetThenCalled, isTrue);
3339 expect (tester.findText ('BottomSheet' ), isNull);
3440
3541 showModalBottomSheet (context: context, child: new Text ('BottomSheet' ));
@@ -41,7 +47,7 @@ void main() {
4147 tester.tapAt (new Point (20.0 , 20.0 ));
4248 tester.pump (); // bottom sheet dismiss animation starts
4349 tester.pump (new Duration (seconds: 1 )); // animation done
44- tester.pump (new Duration (seconds: 2 )); // rebuild frame
50+ tester.pump (new Duration (seconds: 1 )); // rebuild frame
4551 expect (tester.findText ('BottomSheet' ), isNull);
4652 });
4753 });
@@ -50,6 +56,8 @@ void main() {
5056 testWidgets ((WidgetTester tester) {
5157 GlobalKey <PlaceholderState > _bottomSheetPlaceholderKey = new GlobalKey <PlaceholderState >();
5258 BuildContext context;
59+ bool showBottomSheetThenCalled = false ;
60+
5361 tester.pumpWidget (new MaterialApp (
5462 routes: < String , RouteBuilder > {
5563 '/' : (RouteArguments args) {
@@ -69,7 +77,9 @@ void main() {
6977 context: context,
7078 child: new Container (child: new Text ('BottomSheet' ), margin: new EdgeDims .all (40.0 )),
7179 placeholderKey: _bottomSheetPlaceholderKey
72- );
80+ ).then ((_) {
81+ showBottomSheetThenCalled = true ;
82+ });
7383
7484 expect (_bottomSheetPlaceholderKey.currentState.child, isNotNull);
7585 tester.pump (); // bottom sheet show animation starts
@@ -79,7 +89,8 @@ void main() {
7989 tester.fling (tester.findText ('BottomSheet' ), const Offset (0.0 , 20.0 ), 1000.0 );
8090 tester.pump (); // bottom sheet dismiss animation starts
8191 tester.pump (new Duration (seconds: 1 )); // animation done
82- tester.pump (new Duration (seconds: 2 )); // rebuild frame without the bottom sheet
92+ tester.pump (new Duration (seconds: 1 )); // rebuild frame without the bottom sheet
93+ expect (showBottomSheetThenCalled, isTrue);
8394 expect (tester.findText ('BottomSheet' ), isNull);
8495 expect (_bottomSheetPlaceholderKey.currentState.child, isNull);
8596 });
0 commit comments