Invisible: The widget takes up physical space on the screen but is not
visible to user. This can be achieved using Visibility widget.
Gone: The widget doesn't take up any physical space and is completely gone.
This can be achieved using Visibility, if or if-else condition.
Invisible example:
Visibility(
child: Text("Invisible"),
maintainSize: true,
maintainAnimation: true,
maintainState: true,
visible: false,
),
Gone example:
Visibility(
child: Text("Gone"),
visible: false,
),
Using if:
For one child:
Column(
children: <Widget>[
Text('Good Morning'),
if (wishOnePerson) Text(' Mr ABC'),
],
)
For multiple children:
Column(
children: [
Text('Good Morning'),
if (wishAll) ... [
Text('Mr ABC'),
Text('Mr DEF'),
Text('Mr XYZ'),
],
],
)
Using if-else:
For one child:
Column(
children: <Widget>[
if (isMorning) Text('Good Morning')
else Text ('Good Evening'),
],
)
For multiple children:
Column(
children: [
if (beforeSunset) ... [
Text('Good morning'),
Text('Good afternoon'),
] else ... [
Text('Good evening'),
Text('Good night'),
],
],
)