title: dart - pulling static methods from generic extensions
body: <p>Here's the singleton pattern code I was implementing in dart:</p>
  <pre><code>void main() {
    var func = new Functioner();
    print(&quot;The output is: ${func.divide()(8) }&quot;);
  }
  
  class Functioner{
  Function divide(){
    Function letUsDivide = (int x)=&gt;x~/4;
    return letUsDivide;
    }
    
    static Functioner _mThis = null;
    
    Functioner(){
      _mThis = this;
    }
    
    static Functioner getInstance(){
      if(_mThis == null)
        _mThis = new Functioner();
      return _mThis;
    }
    
    
    int divideInts(int a, int b){
      return (a/b).toInt();
    }
    
    
    
  }
  
  class MathGen&lt;T extends Functioner&gt;{
    MathGen();
    
    int divide(){
      Functioner mVal = T;
      double a = 3.5;
      
          
      return T.getInstance().divideInts(3,54); #error
    }
    
  }
    
  </code></pre>
  <p>Since dart's generics allowed making them a subclass of a particular type, I thought static fields and methods would be allowed, but I was wrong. As marked inside the <code>MathGen</code> class with <code>error</code> line says:  <code>the method getInstance() isn't defined for the type 'Type' </code>, but</p>
  <ol>
  <li>shouldn't this syntax <code>T extends Functioner</code> mean that <code>T</code> is atleast a
  <code>Functioner</code> type?</li>
  <li>then why is <code>getInstance()</code> not available</li>
  <li>and how do I cast <code>T</code> to a <code>Functioner</code>? (From what I have found
  dart seems to not have a explicit casting mechanism?)</li>
  </ol>