【问题标题】:Why does my CupertinoActionSheet appear from the top?为什么我的 CupertinoActionSheet 从顶部出现?
【发布时间】:2021-09-08 21:40:51
【问题描述】:

一切正常,只是工作表出现在顶部而不是底部。我希望 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);
          },
        )
      ],
    ),
  );
}

【问题讨论】:

    标签: flutter dart popup flutter-cupertino


    【解决方案1】:

    您需要使用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)),
    ...
    

    【讨论】:

      猜你喜欢
      • 2016-08-15
      • 2013-12-25
      • 2022-11-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-07-15
      • 2015-08-12
      相关资源
      最近更新 更多