如何用无按钮在颤振器中添加分隔线?

问题描述 投票:0回答:3

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

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

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,
                ),
              ),
            ),
          ),
        ],
      ),
    ],
  ),
);

下面是图像:Expected design Image

flutter divider flutter-alertdialog
3个回答
2
投票

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

Cupertino alert dialog

根据您的情况:

showDialog(
    context: context,
    builder: (_) => CupertinoAlertDialog(
        content: Text('Are you sure want to logout?'),
        actions: [
            CupertinoDialogAction(child: Text('Yes'), onPressed: (){}),
            CupertinoDialogAction(child: Text('No'), onPressed: (){}),
        ],
    ),
);

0
投票

您可以使用Divider小部件

Divider(
  color: Colors.black87,
  height: 10.0,
  indent: 5.0,// Starting Space
  endIndent: 5.0 // Ending Space
)

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);
© www.soinside.com 2019 - 2024. All rights reserved.