0

我制作了一个平面按钮图标,但在当前的颤振版本中似乎已经贬值了。我尝试将其升级为文本按钮,但它没有在图标旁边显示文本。

这是必须修改为文本按钮的原始代码。我是否必须定义一个类或函数才能做到这一点?

Row(
            children: [
              FlatButton.icon(
                onPressed: () => print('Live'),
                icon: const Icon(
                  icons.videocam,
                  color: Colors.red,
                ),
                label: Text('Live'),
              ),
            ],
          )

谢谢!:)

4

2 回答 2

0

您可以使用IconButton小部件

Row(
  children: [
    IconButton(
      onPressed: () => print('Live'),
      icon: const Icon(icons.videocam, color: Colors.red),
    ),
    Text('Live'),
  ]
)
于 2021-06-26T02:00:10.863 回答
0

你可以使用TextButton.icon()小部件。这里有一个例子:

TextButton.icon(
  onPressed: () => print('Live'),
  icon: Icon(Icons.videocam_rounded),
  label: Text('Live'),
),

结果如下: 结果

于 2021-06-26T04:26:22.007 回答