堆叠多个图标以使IconButton颤抖

时间:2020-07-03 14:40:42

标签: flutter flutter-layout

我有一个IconButton,想堆叠两个看起来像的图标

enter image description here

我尝试使用Row这样的布局

CircleAvatar(
  radius: avatarRadius,
  child: IconButton(
    icon: Row(
      children: [
        Icon(
          Icons.add,
          color: Colors.white,
        ),
        Icon(
          Icons.message,
          color: Colors.white,
        ),
      ]
    ),
    onPressed: _onAddMessageButtonClick,
  ),
),

但是它给出了错误

A RenderFlex overflowed by 24 pixels on the right.

enter image description here

1 个答案:

答案 0 :(得分:0)

删除IconButton小部件

尝试一下

        CircleAvatar(
          radius: 40,
          child:  GestureDetector(
            onTap: (){
              // perform click here
            },
            child: Row(
                crossAxisAlignment: CrossAxisAlignment.center,
                mainAxisAlignment: MainAxisAlignment.center,
                children: [
                  Icon(
                    Icons.add,
                    color: Colors.white,
                  ),
                  Icon(
                    Icons.message,
                    color: Colors.white,
                  ),
                ]
            ),
          ),
        ),

输出

enter image description here