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

1.9k Views Asked by At

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! :)

2

There are 2 best solutions below

0
On BEST ANSWER

You can use an IconButton widget:

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

you can use TextButton.icon() widget. here an example:

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

and here the result: result