title: Dart Generic Function with Subtype function call
body: <p>I am not sure if this is even possible but here's my setup:</p>
  <p>I have basically 2 Maps holding a special identifier to get some objects.
  these identifier is like a versioning number, i may have data in version 8 that belongs to meta version 5. But at the same time, Meta versions up to 10 may exist and not every meta version holds information about every data, so here's where the _filter kicks in.</p>
  <p>The filter is able to find to any given value the correct object. So far so good.</p>
  <p>My question belongs to the following: (last codeline)
  how am i able to say &quot;if you have no matching candidate, generate me a default value&quot;
  For this purpose, i tried to force a named constructor with a super class for &quot;Data&quot; and &quot;Meta&quot; called &quot;BasicInformation&quot;.
  But even if i implement this, how do i call something like T.namedConstructor(); ?</p>
  <pre><code>class Repo{
    Map&lt;int, Data&gt; mapData;
    Map&lt;int, Meta&gt; mapMeta;
      
    Data getData(int value)
    {
      return _filter&lt;Data&gt;(mapData, value);
    }
  
    Meta getMeta(int value)
    {
      return _filter&lt;Data&gt;(mapMeta, value);
    }
  
    T _filter&lt;T extends BasicInformation&gt;(Map&lt;int, T&gt;, int value)
    {
      //fancy filtering technique 
      //....
      //speudo code
      if (found) return map[found]; //speudo code
        
      else return T.generateDefault();
    }
  }
  </code></pre>