【问题标题】:IconButtons take too much spaceIconButtons 占用太多空间
【发布时间】:2021-05-15 15:02:13
【问题描述】:

我将你的 IconButtons 放在第一个 Expanded 中。但是他们在他们周围占据了太多的空间。如何让它们彼此靠近?

Row(
      mainAxisAlignment: MainAxisAlignment.center,
      children: [
        Expanded(
          child: Row(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              IconButton(
                iconSize: 10,
                icon: FaIcon(FontAwesomeIcons.plus),
                onPressed: null,
              ),
              IconButton(
                iconSize: 10,
                icon: FaIcon(FontAwesomeIcons.asterisk),
                onPressed: null,
              ),
              IconButton(
                iconSize: 10,
                icon: FaIcon(FontAwesomeIcons.hashtag),
                onPressed: null,
              ),
            ],
          ),
        ),
        Expanded(...),
        Expanded(...),
      ],
    )
  ],
);

【问题讨论】:

    标签: flutter


    【解决方案1】:

    你可以使用 RawMaterialButtons,然后你使用 BoxConstraints 来设置它周围的大小,看看这个 aswer:https://stackoverflow.com/a/54963347/2831595

    【讨论】:

      【解决方案2】:

      你可以试试这个:

      AspectRatio(
        aspectRatio: 1,
        child: IconButton(
          icon: Icon(Icons.ac_unit),
          onPressed: () {},
        ),
      );
      

      【讨论】:

        猜你喜欢
        • 2012-05-15
        • 1970-01-01
        • 2011-09-08
        • 2022-07-13
        • 2020-05-12
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多