Use case
Currently, flutter only supports square icons. Icon creates a SizedBox with equal width and height.
Packages like font_awesome_flutter, which contain rectangular icons, have to reimplement the Icon class and change the line where flutter defines the SizedBox.
This leads to a lot of duplicate code, unnecessary maintenance costs, unexpected behavior for developers, and slow adaptation of new features added to Icon.
Related issues: fluttercommunity/font_awesome_flutter#132, fluttercommunity/font_awesome_flutter#204, fluttercommunity/font_awesome_flutter#201, fluttercommunity/font_awesome_flutter#198
Proposal
There are multiple possible solutions:
- Add an aspectRatio attribute to
IconData which is then used to scale the Icon width accordingly
- Allow overriding a method in
Icon which sets the icon dimensions (would keep FaIcon in font_awesome_flutter)
Automatically obtain icon dimensions using IntrinsicWidth/IntrinsicHeight (costly)
Use case
Currently, flutter only supports square icons.
Iconcreates aSizedBoxwith equal width and height.Packages like font_awesome_flutter, which contain rectangular icons, have to reimplement the
Iconclass and change the line where flutter defines theSizedBox.This leads to a lot of duplicate code, unnecessary maintenance costs, unexpected behavior for developers, and slow adaptation of new features added to
Icon.Related issues: fluttercommunity/font_awesome_flutter#132, fluttercommunity/font_awesome_flutter#204, fluttercommunity/font_awesome_flutter#201, fluttercommunity/font_awesome_flutter#198
Proposal
There are multiple possible solutions:
IconDatawhich is then used to scale theIconwidth accordinglyIconwhich sets the icon dimensions (would keepFaIconin font_awesome_flutter)Automatically obtain icon dimensions usingIntrinsicWidth/IntrinsicHeight(costly)