title: Flutter if statement within widget
body: <p>Not sure why this if statement is not working:</p>
  
  <pre><code>  Widget build(BuildContext context) {
      return Container(
        child: Column(
          children: &lt;Widget&gt;[
            if (text.length &gt; 0) {
               for (var val in text) Center(child: etc..)
              }
          ],
        ),
  )
  </code></pre>
  
  <p>The code within the if statement (removed for now) works fine without the if statement, but as soon as I add it I get the error <code>The element type 'Map' can't be assigned to the list type 'Widget'</code>.</p>
  
  <p>How should I compose this if statement within a widget? I realise it's within a <code>return</code> statement but not sure why the for loop is fine but not the if statement..</p>