Disable drag down to close showModalBottomSheet Disable drag down to close showModalBottomSheet flutter flutter

Disable drag down to close showModalBottomSheet


Set enableDrag to false

bool enableDrag

If true, the bottom sheet can dragged up and down and dismissed by swiping downwards.

https://docs.flutter.io/flutter/material/BottomSheet/enableDrag.html


you can try to wrap builder's result with GestureDetector with onVerticalDragStart = (_) {}

showModalBottomSheet(  context: context,  builder: (context) => GestureDetector(    child: **any_widget_here**,    onVerticalDragStart: (_) {},  ),  isDismissible: false,  isScrollControlled: true,);


If you still want to have the scroll inside the modal without the user drag and close it, you can use this:

                  showModalBottomSheet(                    context: context,                    enableDrag: false,                    shape: RoundedRectangleBorder(                      borderRadius: BorderRadius.vertical(                        top: Radius.circular(20),                      ),                    ),                    clipBehavior: Clip.antiAliasWithSaveLayer,                    builder: (context) => DraggableScrollableSheet(                      expand: false,                      initialChildSize: 0.9,                      minChildSize: 0.5,                      maxChildSize: 0.9,                      builder: (context, scrollController) {                        return SingleChildScrollView(                          child: new Container(                            color: Colors.white,                            child: buildTitleWidget(),                          ),                        );                      },                    ),                    isDismissible: false,                    isScrollControlled: true,                  );

The trick is not to add scrollController to the SingleChildScrollView

                      builder: (context, scrollController) {                        return SingleChildScrollView(                          controller: scrollController            <-- HERE                          child: new Container(                            color: Colors.white,                            child: buildTitleWidget(),                          ),                        );                      },