Search code examples
flutterflatbutton

How do I change a flatbutton.icon to a textbutton in Flutter?


I have made a flatbutton icon, but it seems this is depreciated in the current flutter version. I have tried to upgrade it to a text button, but it does not show the text next to the icon.

This is the original code that has to be adapted to become a text button. Should I have to define a class or function to make it so?

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

Thx! :)


Solution

  • You can use an IconButton widget:

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