语法 if ...[] else ...[] 适合此场景:
return Column(
children: [
if (isSelected) ...[
Container(color: Colors.red),
] else ...[
Container(color: Colors.green)
],
],
);
语法 if ...[] else ...[] 适合此场景:
return Column(
children: [
if (isSelected) ...[
Container(color: Colors.red),
] else ...[
Container(color: Colors.green)
],
],
);