gpt-3.5-turbo-0613· openai
Suzhen/CodeChat
Hi! How to close flutter MODAL bottom sheet outside of bottom sheet itself
- User
Hi! How to close flutter MODAL bottom sheet outside of bottom sheet itself
- Assistant
To close a Flutter modal bottom sheet outside of the bottom sheet itself, you can follow these steps:
-
Use the
showModalBottomSheetfunction to display the bottom sheet. This function returns aFuturethat resolves to the value that was passed to theNavigator.popmethod.dartvoid _showBottomSheet(BuildContext context) { showModalBottomSheet( context: context, builder: (BuildContext context) { return Container( child: Text("My Bottom Sheet"), ); }, ).then((value) { // Handle the value returned, if any }); } -
Wrap your main widget tree with a
GestureDetectorwidget to capture the tap events outside of the bottom sheet.dart
-