0

我必须为我的警报对话框添加一个水平和垂直分隔线,如图所示。

我正在尝试的唯一方法是在这里,最好不要引用此代码,但我需要按照图像中的预期进行设计。

AlertDialog(
  shape: RoundedRectangleBorder(
    borderRadius: BorderRadius.all(Radius.circular(10.0))
  ),
  content: Column(
    mainAxisSize: MainAxisSize.min,
    children: <Widget>[
      new Row(
        children: <Widget>[
          Expanded(
            child: Container(
              decoration: BoxDecoration(
                border: Border.all(color: Colors.black)
              ),
              child: new GestureDetector(
                onTap: () => callback(AlertButton.positive),
                child: new Text(
                  positiveActionText,
                  textAlign: TextAlign.center,
                ),
              ),
            ),
          ),
          Expanded(
            child: Container(
              decoration: BoxDecoration(
                border: Border.all(color: Colors.black)
              ),
              child: new GestureDetector(
                onTap: () => callback(AlertButton.negative),
                child: new Text(
                  negativeActionText,
                  textAlign: TextAlign.center,
                ),
              ),
            ),
          ),
        ],
      ),
    ],
  ),
);

下面是一张图片: 预期的设计图片

4

3 回答 3

2

您可以使用CupertinoAlertDialog,默认情况下具有以下几行:

库比蒂诺警报对话框

在你的情况下:

showDialog(
    context: context,
    builder: (_) => CupertinoAlertDialog(
        content: Text('Are you sure want to logout?'),
        actions: [
            CupertinoDialogAction(child: Text('Yes'), onPressed: (){}),
            CupertinoDialogAction(child: Text('No'), onPressed: (){}),
        ],
    ),
);
于 2020-01-10T12:21:48.723 回答
0

您可以使用 Divider 小部件

Divider(
  color: Colors.black87,
  height: 10.0,
  indent: 5.0,// Starting Space
  endIndent: 5.0 // Ending Space
)
于 2020-01-10T12:22:42.203 回答
0
var alert = new CupertinoAlertDialog(
  title: new Text("Alert"),
  content: new Text("Test Sample 123."),
  actions: <Widget>[
    new CupertinoDialogAction(
      child: const Text('Discard'),
      isDestructiveAction: true,
      onPressed: (){}
    ),
    new CupertinoDialogAction(
        child: const Text('Cancel'),
        isDefaultAction: true,
        onPressed: () {}
    ),
  ],
);

showDialog(context: context, child: alert);
于 2020-01-10T12:43:08.277 回答