为什么我的 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)),...

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...