I am using showBottomSheet in flutter to show a persistent bottom sheet. how can I prevent flutter showBottomSheet from being dismissed by dragging down? I have added my code below. you can place a rawmaterialbutton and with onpressed call this function.
void itemChooser(
{int currentItemCount, String name, callBack, BuildContext context}) {
int chosen = 0;
showBottomSheet(
context: context,
builder: (BuildContext context) {
return Container(
height: 500,
color: Colors.white,
);
});
}
Set enableDrag
property of BottomSheet
to false
its true
by default
BottomSheet(
enableDrag: false,
builder: //builder
),
Refer here for more info on BottomSheet
Just wrap your child with GestureDetector
and set onVerticalDragStart: (_) {}
,
showBottomSheet(
context: context,
builder: (context) => GestureDetector(
child: *your_widget*,
onVerticalDragStart: (_) {},
),
);
If you use showModalBottomSheet
, simply use enableDrag
property:
showModalBottomSheet(
context: context,
builder: (context) => yourWidget,
enableDrag: false,
);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With