title: Calling method on generic type Dart
body: <p>I am trying to get a way to call method on a generic type. But can't find it.</p>
  
  <p>In swift I can write like:</p>
  
  <pre><code>protocol SomeGeneric {
      static func createOne() -&gt; Self
      func doSomething()
  
  }
  
  class Foo: SomeGeneric {
      required init() {
  
      }
      static func createOne() -&gt; Self {
          return self.init()
      }
  
      func doSomething() {
          print("Hey this is fooooo")
      }
  }
  
  class Bar: SomeGeneric {
      required init() {
  
      }
  
      static func createOne() -&gt; Self {
          return self.init()
      }
  
      func doSomething() {
          print("Hey this is barrrrrrr")
      }
  }
  
  func create&lt;T: SomeGeneric&gt;() -&gt; T {
      return T.createOne()
  }
  
  let foo: Foo = create()
  let bar: Bar = create()
  
  foo.doSomething() //prints  Hey this is fooooo
  bar.doSomething() //prints  Hey this is barrrrrrr
  </code></pre>
  
  <p>In Dart I tried:</p>
  
  <pre><code>abstract class SomeGeneric {
    SomeGeneric createOne();
    void doSomething();
  }
  
  class Foo extends SomeGeneric {
    @override
    SomeGeneric createOne() {
      return Foo();
    }
  
    @override
    void doSomething() {
      print("Hey this is fooooo");
    }
  }
  
  class Bar extends SomeGeneric {
    @override
    SomeGeneric createOne() {
      return Bar();
    }
  
    @override
    void doSomething() {
      print("Hey this is barrrrr");
    }
  }
  
  T create&lt;T extends SomeGeneric&gt;() {
    return T.createOne();//error: The method 'createOne' isn't defined for the class 'Type'.
  }
  </code></pre>
  
  <p>The code gives error <code>The method 'createOne' isn't defined for the class 'Type'</code>
  How to fix this?. If this is possible, it would save lot of time and tons of lines of code.</p>