Closed
Description
Flutter code contains UI descriptions that are naturally ordered, with a set of arguments typically specified in the rough order they appear on the screen, e.g.:
Widget buildBody() {
return Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text('Text 1'),
Text('Text 2'),
Text('Text 3'),
],
);
}
However, when some of these elements need to be conditionally shown, the developer is forced to restructure the method "backwards"; with the conditional code first, and then the code for what surrounds the conditional code:
Widget buildBody() {
List<Widget> children;
children.add(Text('Text 1'));
if (someCondition == true) {
children.add(Text('Text 2'));
}
children.add(Text('Text 3'));
return Column(
mainAxisAlignment: MainAxisAlignment.center,
children: children,
);
}
The present issue requests support for some way of writing conditional code "as part of the statements".