giannik28
giannik28

Reputation: 463

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

Upvotes: 2

Views: 2287

Answers (2)

keepant
keepant

Reputation: 316

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

Upvotes: 2

enzo
enzo

Reputation: 11531

You can use an IconButton widget:

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

Upvotes: 0

Related Questions