i am developing a bottom sheet which contains a TextField, i noticed that every time the keyboard is shown, the bottom sheet’s height reduced, then recovered when keyboard is hidden, this is my demo code
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
resizeToAvoidBottomInset: false,
body: Center(
child: ElevatedButton(
onPressed: () {
showModalBottomSheet(
context: context,
builder: (_) {
return const SafeArea(
child: SizedBox(
height: 500,
child: TextField(),
),
);
}
);
},
child: const Text("show bottom sheet"),
),
)
);
}
}
perhaps is the SafeArea became hidden when keyboard is shown? how can i keep the bottom sheet’s hight the same while keyboard is shown
2
Answers
i just noticed that there is a parameter
maintainBottomViewPadding
inSafe Area
, when i set it true, bottom sheet's height will not change while keyboard is shown