Dart: Factory Constrcutor

Constructors in Dart are very flexible, allowing definition default or named constructor with positional or named parameters, optional, required or default values. 

				
					abstract class IHello {                 // Define interface
    String sayHello(String msg);    
    factory IHello() {                  // factory constructor returns
        return new Hello();             // instance of Hello
    }
}
class Hello implements IHello {
  sayHello(String name) {
    return "Hello $name";
  }
}
main() {
    IHello myHello = new IHello();
    var msg = myHello.sayHello("John");
    print(msg);
}