flutter - 为什么我的 CupertinoActionSheet 从顶部出现?
问题描述
一切正常,只是工作表出现在顶部而不是底部。我希望 cupertinoactionsheet 默认从底部显示。
我目前正在使用 Android 模拟器,但我怀疑这是否是工作表从顶部出现的原因。
附上我的代码
Future<bool> showReportDialog({
@required BuildContext context,
}) async {
return showCupertinoDialog(
context: context,
builder: (context) => CupertinoActionSheet(
title: const Text('Make Your Space Safe',
style: TextStyle(
fontSize: 18, color: Colors.black, fontWeight: FontWeight.w600)),
message: const Text('What to report this user for?',
style: TextStyle(
fontSize: 16.5,
color: Colors.black38,
fontWeight: FontWeight.w500)),
actions: <CupertinoActionSheetAction>[
CupertinoActionSheetAction(
child: const Text(
'Scam',
),
onPressed: () {
afterReport();
print("Reported user for SCAM");
},
),
CupertinoActionSheetAction(
child: const Text('Bots/Spam'),
onPressed: () {
afterReport();
print("Reported user for BOTS/SPAM");
},
),
CupertinoActionSheetAction(
child: const Text('Sexually harassing'),
onPressed: () {
afterReport();
print("Reported user for SEXUALLY HARASSSING");
},
),
CupertinoActionSheetAction(
child: const Text('Offensive/abusive behaviour'),
onPressed: () {
afterReport();
print('Reported user for OFFENSIVE/ABUSIVE BEHAVIOUR');
},
),
CupertinoActionSheetAction(
child: const Text('I want to write more',
style: TextStyle(fontWeight: FontWeight.bold)),
onPressed: () {
Navigator.push(
context,
new MaterialPageRoute(
builder: (BuildContext context) => ReportUser()));
},
),
CupertinoActionSheetAction(
child: const Text('Cancel'),
onPressed: () {
Navigator.pop(context);
},
)
],
),
);
}
解决方案
您需要使用showCupertinoModalPopup
而不是showCupertinoDialog
:
showCupertinoModalPopup(
context: context,
builder: (context) => CupertinoActionSheet(
title: const Text('Make Your Space Safe',
style: TextStyle(
fontSize: 18,
color: Colors.black,
fontWeight: FontWeight.w600)),
...
推荐阅读
- perl - 在 Template Toolkit 中按值而不是键对哈希引用进行排序
- c++ - 在应用程序终止时关闭 COM 端口
- kubernetes - 有没有像 Istio 这样支持 LXC 容器的服务网格实现?
- javascript - 如果在 textarea 中输入空格,则 Make 按钮将被禁用
- reactjs - Mapbox 地图未显示(react-map-gl)
- node.js - 在perl中将JSON缓冲区转换为字符串
- r - 我如何在 R 函数中传递字符串
- reactjs - 在反应中从 object.keys 返回重复的结果
- python - 使用 iconbitmap() 时图标不出现
- android - 未找到处理 Intent 的活动(从片段打开浏览器)