title: Why use if and for within a list definition in Dart?
body: <p>Dart supports using &quot;if&quot; and &quot;for&quot; during creation of a list :</p>
  <pre><code>var nav = [
    'Home',
    'Furniture',
    'Plants',
    if (promoActive) 'Outlet'
  ];
  </code></pre>
  <p>and:</p>
  <pre><code>var listOfInts = [1, 2, 3];
  var listOfStrings = [
    '#0',
    for (var i in listOfInts) '#$i'
  ];
  assert(listOfStrings[1] == '#1');
  </code></pre>
  <p>What is the point of this ? How is it better than creating a list, and appending to it afterwards like in other programming languages:</p>
  <pre><code>var nav = [
    'Home',
    'Furniture',
    'Plants',
  ];
  
  if (promoActive) nav.add('Outlet');
  </code></pre>