title: Class constructor which allows different subtypes as arguments
body: <p>I am trying to create a class which where the constructor can accept a List, the elements of which must be instances of a subclass of a specific class. Below is a minimal example of what I am working on. I would like the <code>DataSet</code> constructor to accept any list of instances of a subclass of <code>Column</code> i.e. <code>IntegerColumn</code> or <code>DoubleColumn</code>. However, the code below will only accept <code>List&lt;Column&gt;</code> and not <code>List&lt;IntegerColumn&gt;</code> and <code>List&lt;DoubleColumns&gt;</code>, and creates the error: <code>The element type 'DoubleColumn' can't be assigned to the list type 'Column'.</code>. Is it possible to specify that the DataSet constructor can accept a list of any subclass of <code>Column</code>?</p>
  <pre class="lang-dart prettyprint-override"><code>class Column {
    List data;
    String name;
  }
  
  class IntegerColumn {
    List&lt;int&gt; data;
    String name = 'col1';
    IntegerColumn(this.data);
  }
  
  class DoubleColumn {
    List&lt;double&gt; data;
    String name = 'col2';
    DoubleColumn(this.data);
  }
  
  class DataSet {
    Map&lt;String, Column&gt; columns;
    DataSet(List&lt;Column&gt; columns) {
      Map&lt;String, Column&gt; namedColumns = {};
      for (Column column in columns) {
        namedColumns[column.name] = column;
      }
      this.columns = namedColumns;
    }
  }
  
  void main() {
    DataSet dataSet = DataSet([
      IntegerColumn([1, 2, 3]), // The element type 'DoubleColumn' can't be assigned to the list type 'Column'.
      DoubleColumn([1.1, 2.2, 3.3])
    ]);
    print(dataSet);
  }
  </code></pre>