2

我想删除 Row 小部件中两个 IconButton 之间的一些额外空间我尝试了更多但仍然无法删除小部件之间的空间

Column(
  children: <Widget>[
    Row(
      mainAxisAlignment: MainAxisAlignment.spaceBetween,
      children: <Widget>[
        Text("Home",
          style: TextStyle(
            fontWeight: FontWeight.bold,
            fontSize: 15,
            color: Colors.black
          )
        ),
        Row(
          mainAxisAlignment: MainAxisAlignment.end,
          children: <Widget>[
            IconButton(
              icon: Icon(
                Icons.edit,
                color: Colors.black,
                size: 20,
              ),
              onPressed: () {
                IntelUtility.navigateToScreen(
                  context, EditHomeAddressScreen()
                );
              },
            ),
            IconButton(
              icon: Icon(
                Icons.delete,
                color: Colors.black,
                size: 20,
              ),
              onPressed: () {},
            ),
          ],
        ),
      ],
    ),
  ],
),

请帮助解决这个问题我遇到了麻烦:(

图片

4

3 回答 3

2

您可以像这样使用 CupertinoButton,而不是使用 IconButton:

CupertinoButton(
  minSize: double.minPositive,
  padding: EdgeInsets.zero,
  child: Icon(
    Icons.delete,
    color: Color.black,
    size: 20
  ),
  onPressed: () {},
)
于 2020-02-13T09:03:03.577 回答
1

将参数添加padding: EdgeInsets.all(0)到 IconButton。

IconButton(
          padding: EdgeInsets.all(0),
          icon: Icon(
            Icons.delete,
            color: Colors.black,
            size: 20,
          ),
          onPressed: () {},
        )
于 2020-02-13T09:00:54.590 回答
0

你的答案是 BoxConstraints

Row(
          mainAxisAlignment: MainAxisAlignment.end,
          children: <Widget>[
            IconButton(
              constraints: BoxConstraints.tight(Size.fromWidth(30)),
              icon: Icon(
                Icons.edit,
                color: Colors.black,
                size: 20,
              ),
              onPressed: () {
                IntelUtility.navigateToScreen(
                  context, EditHomeAddressScreen()
                );
              },
            ),
            IconButton(
              constraints: BoxConstraints.tight(Size.fromWidth(30)),
              icon: Icon(
                Icons.delete,
                color: Colors.black,
                size: 20,
              ),
              onPressed: () {},
            ),
          ],
        ),

你可以改变constraints: BoxConstraints.tight(Size.fromWidth(30)),任何你想要的

于 2020-02-13T09:01:09.233 回答