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.
2
Answers
Hello there is a comman difference between both button
for : –
You have to give icon because that is required
You don’t need to give icon because that is not required
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.