It may be a stupid question but I don't know how to figure out it:
How to prevent CupertinoActionSheet/showCupertinoModalPopup from dismissing while you tap outside of it?
I made a selector list for gps search (radius) and I have to prevent user for dismissing it without any value selected.
_showDialog2() {
Platform.isAndroid
? showDialog(
barrierDismissible: false,
context: context,
builder: (context) {
return RadiusSelectorDialog();
})
: showCupertinoModalPopup(
context: context,
builder: (context) {
return CupertinoRadiusSelectorPopup();
}).then((value) => print(value));
}
In case of Android dialog it's just enough to set barierDismissable to false. But in showCupertinoModalPopup this kind of property do not exist. I've tried to wrap it with Absorb pointer but it can still be dismissed when you tap outside.
my actionSheet
class _CupertinoRadiusSelectorPopupState
extends State<CupertinoRadiusSelectorPopup> {
Color color = Colors.grey[900];
double fontSize = 15.0;
@override
Widget build(BuildContext context) {
return CupertinoActionSheet(
title: Text('Search in range:',
style: TextStyle(
color: Colors.black,
fontSize: 18,
)),
message: Text('Search for points in selected range'),
actions: [
CupertinoActionSheetAction(
onPressed: () => onPressed("10"),
child: Text('10 km',
style: TextStyle(color: color, fontSize: fontSize))),
CupertinoActionSheetAction(
onPressed: () => onPressed("25"),
child: Text('25 km',
style: TextStyle(color: color, fontSize: fontSize))),
CupertinoActionSheetAction(
onPressed: () => onPressed("50"),
child: Text('50 km',
style: TextStyle(color: color, fontSize: fontSize))),
CupertinoActionSheetAction(
onPressed: () => onPressed("100"),
child: Text('100 km',
style: TextStyle(color: color, fontSize: fontSize))),
],
);
}
onPressed(String value) {
print(value);
Navigator.pop(context, value);
}
}
question from:
https://stackoverflow.com/questions/66045528/how-to-prevent-dismissing-cupertinoactionsheet-showcupertinomodalpopup 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…