如何从 Flutter 中的 AlertDialog 中删除对称边距?

How to remove symmetric margin from AlertDialog in Flutter?

我正在显示 AlertDialogontap InkWell 一切都很好只是一件事我不知道顶部和底部的边距来自哪里。

这是我得到的结果

这是我的代码:

    AlertDialog(
      content: Center(
        child: Column(
          mainAxisSize: MainAxisSize.min,
          children: [
            const Text("PARACETAMOL MACROPHARMA 10 MG/ML",
              style: TextStyle(
                  fontFamily: "cairo-bold",
                  fontSize: 18),
            ),
            const Text("ANALGESIQUE ANTIPYRETIQUE",
              style: TextStyle(fontFamily: "cairo"),
            ),
            Container(
              margin: const EdgeInsets.symmetric(
                  horizontal: 10, vertical: 10),
              padding: const EdgeInsets.fromLTRB(
                  20, 5, 20, 5),
              decoration: const BoxDecoration(
                color: Colors.green,
                borderRadius: BorderRadius.all(
                    Radius.circular(10)),
              ),
              child: const Text("PPV : 30.1 DH",
                style: TextStyle(
                  fontFamily: "cairo",
                  color: Colors.white,
                ),
              ),
            ),
            const Text(" PARACETAMOL / 1G",
              style: TextStyle(fontFamily: "cairo"),
            ),
          ],
        ),
      ),
      actions: <Widget>[],
     ),
    );

AlertDialogcontent 中删除 Center 小部件。默认居中。

AlertDialog(
  content: Column(
    mainAxisSize: MainAxisSize.min,
    children: [

删除 center 小部件并使用 title。试试这个:

AlertDialog(
  title:  const Text(
    "PARACETAMOL MACROPHARMA 10 MG/ML",
    style: TextStyle(fontFamily: "cairo-bold", fontSize: 18),
  ),
  content: Column(
    mainAxisSize: MainAxisSize.min,
    children: [

      const Text(
        "ANALGESIQUE ANTIPYRETIQUE",
        style: TextStyle(fontFamily: "cairo"),
      ),
      Container(
        margin: const EdgeInsets.symmetric(horizontal: 10, vertical: 10),
        padding: const EdgeInsets.fromLTRB(20, 5, 20, 5),
        decoration: const BoxDecoration(
          color: Colors.green,
          borderRadius: BorderRadius.all(Radius.circular(10)),
        ),
        child: const Text(
          "PPV : 30.1 DH",
          style: TextStyle(
            fontFamily: "cairo",
            color: Colors.white,
          ),
        ),
      ),
      const Text(
        " PARACETAMOL / 1G",
        style: TextStyle(fontFamily: "cairo"),
      ),
    ],
  ),
  actions: <Widget>[],
);