flutter
flutter copied to clipboard
Proposal to add an IconImage widget
Is there an existing issue for this?
- [X] I have searched the existing issues
- [X] I have read the guide to filing a bug
Use case
Just like one can create ImageProviders from assets, network, and memory. There should be a way to create an image from IconData. It will save a lot of time and will be very convenient as the builtin icons can be directly used instead of downloading it as a png/jpg and adding it to the assets.
We already have a ImageIcon widget. Why not have something the other way around?
Example Use Case:
SwitchListTile requires activeThumbImage and inactiveThumbImage which need to be ImageProviders. I want to use pre-built icons that are already shipped with flutter, but unable to do so directly as there is no way to convert an icon into an image.
Proposal
An IconImage widget that provides Icons.heart (example) as an Image.
We already have a ImageIcon widget. Why not have something the other way around?
i don't think its trivial to do so, as Icon is actually text + fontFamily. it'll be simpler to have 2 APIs, one for each. although i'll let others with more experience o weigh in on this.
SwitchListTile requires activeThumbImage and inactiveThumbImage which need to be ImageProviders. I want to use pre-built icons that are already shipped with flutter, but unable to do so directly as there is no way to convert an icon into an image.
for this particular usecase, SwitchListTile.thumbIcon was recently added (PR), which enables using an icon for a thumb. (Switch has had this since a long time). but, looks like its not in stable yet, so it'll be released soon.
Thanks for looking into it @werainkhatri and also for letting me know about SwitchListTile.thumbIcon which is my current use case.
Will definitely wait for a reply on ImageIcon from others.