skip to Main Content

What’s the difference between FilledButton.tonalIcon and FilledButton.icon ?
I checked their constructor, both is same.

2

Answers


  1. Hello there is a comman difference between both button

    for : –

    1)  FilledButton.icon(
                onPressed: () {},
                icon: const Icon(Icons.home),
                label: const Text('Hello'),
       ),
    

    You have to give icon because that is required

       2)  FilledButton.tonal(
                onPressed: () {},
                child: const Text('Hello'),
          ),   
    

    You don’t need to give icon because that is not required

    Login or Signup to reply.
  2. In Flutter, FilledButton.tonalIcon and FilledButton.icon are the same, as you observed. Both constructors are available for creating buttons with icons. However, they might be named differently for clarity or consistency within a library or framework.
    f you’re seeing both constructors and they have identical implementations and parameters, it’s likely that they are aliases or synonyms provided for convenience or to maintain consistency in the API.

    In such cases, you can use either FilledButton.tonalIcon or FilledButton.icon interchangeably to create a button with an icon, and they should behave the same way. The choice between them may depend on personal preference or the naming conventions adopted within the project or library you’re working with.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search