Unverified Commit 45cf2792 authored by Zain Ur Rehman's avatar Zain Ur Rehman Committed by GitHub

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

parent 6a2dfa9f
...@@ -375,6 +375,8 @@ class _ModalBottomSheetState<T> extends State<_ModalBottomSheet<T>> { ...@@ -375,6 +375,8 @@ class _ModalBottomSheetState<T> extends State<_ModalBottomSheet<T>> {
return AnimatedBuilder( return AnimatedBuilder(
animation: widget.route!.animation!, animation: widget.route!.animation!,
child: Padding(
padding: MediaQuery.of(context).viewInsets,
child: BottomSheet( child: BottomSheet(
animationController: widget.route!._animationController, animationController: widget.route!._animationController,
onClosing: () { onClosing: () {
...@@ -391,6 +393,7 @@ class _ModalBottomSheetState<T> extends State<_ModalBottomSheet<T>> { ...@@ -391,6 +393,7 @@ class _ModalBottomSheetState<T> extends State<_ModalBottomSheet<T>> {
onDragStart: handleDragStart, onDragStart: handleDragStart,
onDragEnd: handleDragEnd, onDragEnd: handleDragEnd,
), ),
),
builder: (BuildContext context, Widget? child) { builder: (BuildContext context, Widget? child) {
// Disable the initial animation when accessible navigation is on so // Disable the initial animation when accessible navigation is on so
// that the semantics are added to the tree at the correct time. // that the semantics are added to the tree at the correct time.
......
...@@ -726,6 +726,41 @@ void main() { ...@@ -726,6 +726,41 @@ void main() {
expect(retrievedRouteSettings, routeSettings); 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 { class _TestPage extends StatelessWidget {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment