[showModalBottomSheet] fix: showModalBottomSheet does not move along keyboard (#71636)

This commit is contained in:
Zain Ur Rehman
2021-01-22 06:19:04 +05:00
committed by GitHub
parent 6a2dfa9f4f
commit 45cf27923a
2 changed files with 53 additions and 15 deletions

View File

@@ -726,6 +726,41 @@ void main() {
expect(retrievedRouteSettings, routeSettings);
});
testWidgets('showModalBottomSheet should move along on-screen keyboard',
(WidgetTester tester) async {
late BuildContext savedContext;
// Show a keyboard (simulate by space at the bottom of the screen).
await tester.pumpWidget(
MaterialApp(
home: MediaQuery(
data: const MediaQueryData(viewInsets: EdgeInsets.only(bottom: 200)),
child: Builder(
builder: (BuildContext context) {
savedContext = context;
return Container();
},
),
),
),
);
await tester.pump();
expect(find.text('BottomSheet'), findsNothing);
showModalBottomSheet<void>(
context: savedContext,
builder: (BuildContext context) {
return const Text('BottomSheet');
},
);
await tester.pumpAndSettle();
expect(find.text('BottomSheet'), findsOneWidget);
expect(tester.getBottomLeft(find.text('BottomSheet')).dy, 600);
});
}
class _TestPage extends StatelessWidget {