title: Why can I do a ternary but not an if statement
body: <p>Why does the first work, but the second does not? The issue with the first is that null throws assertion exception since the widget cannot be null. what is the best practice in this scenario?</p>
  
  <pre class="lang-dart prettyprint-override"><code>Row(
       children: listOfWidgets != null ? listOfWidgets : null
  )
  </code></pre>
  
  <pre class="lang-dart prettyprint-override"><code>Row(
       children: if (listOfWidgets != null) listOfWidgets;
  )
  </code></pre>
  
  <p>Current workaround:</p>
  
  <pre class="lang-dart prettyprint-override"><code>void List&lt;Widget&gt; _rowWidgets() {
       if(listOfWidgets != null) return listOfWidgets;
  }
  
  Row(
       children: _rowWidgets();
  )
  </code></pre>