Sometimes, it can be useful to show nothing where an icon would normally be, while using the same amount of space (such as in a list where only some items have icons).
Does Flutter let you do this easily?
Sometimes, it can be useful to show nothing where an icon would normally be, while using the same amount of space (such as in a list where only some items have icons).
Does Flutter let you do this easily?
2
Answers
The
Icon
widget allows setting theicon
tonull
, which achieves the desired behaviour.From the docs:
For example, with a nullable widget
myIcon
:Another solution is to use the Visibility widget, which allows you to hide any widget based on a straightforward condition