title: What's the best way to change the size of a list in Dart?
body: <ul>
  <li>I have a list with <code>oldLength</code> items. </li>
  <li>I want it to have <code>newLength</code> items. </li>
  <li>If <code>newLength &lt; oldLength</code>, I just want to cut the extra items. </li>
  <li>If <code>newLength &gt; oldLength</code>, I want to fill it with nulls.</li>
  </ul>
  
  <p>I wrote this:</p>
  
  <pre><code>List&lt;T&gt; cutList&lt;T&gt;(List&lt;T&gt; oldList, int newLength) {
      return new List.generate(newLength, (index) {
        if (index &lt; oldList.length) return oldList[index];
        else return null;
     });
  }
  </code></pre>
  
  <p>Is there a better way, in terms of simplicity? And in terms of efficiency?</p>