首页 > 解决方案 > 如何在颤动中为图标按钮添加标签

问题描述

如何给这个标签IconButton

IconButton(
  icon: Image.asset('path/the_image.png'),
  iconSize: 50,
  onPressed: () {},
)

标签: flutter

解决方案


使用ListTile小部件如下:

如果您希望标签成为 ListTile 的标题,请使用此选项:

ListTile(
           leading: IconButton( icon: Image.asset('path/the_image.png'), iconSize: 50, onPressed: () {}, ),
           trailing: Text('Your label'),
        ),

或者,如果您希望它是尾随的,请使用:

ListTile(
           leading: IconButton( icon: Image.asset('path/the_image.png'), iconSize: 50, onPressed: () {}, ),
           title: Text('Your label'),
        ),

推荐阅读