We have already seen ( errorText example ) that how to use conditional express in Flutter.
I want to place an Icon in a widget ListView or what ever want to be which is changing based on some condition, say, Show a cloud Icon when I synced the data otherwise just show a regular offline Icons.
How to conditionally place a cloud icon inside a Flutter Scaffold or any widget ?
We can use a conditional expression which only accept a bool expression. Let create a bool variable. You can change the value of the variable programmatically almost any event handler or in setState block.
Then you can write a conditional expression before the placement of widget as follows
isCloud? Icon(Icons.cloud_circle): Icon(Icons.cloud_off)
Simple isn’t. If you interested in the complete project just go ahead