Is it possible to create a logic that allows the container to only display only text (image above) or text and image (image below) when image is available.
Asked
Active
Viewed 19 times
-1
-
You can check which condition is true and display what you want on each condition. The easiest way is with (if else). But be careful to manipulate the state the right way – Fotis Psarris Mar 23 '23 at 08:41
1 Answers
0
Let's say person
is an object that has a name
and optionally an image
. Then this is a way to write it
Column(
children: [
Text(person.name),
if (person.image != null) Image.network(person.image!)
],
)

Ivo
- 18,659
- 2
- 23
- 35