Many methods like complete in class Completer are marked “abstract”, but in fact It can be directly invoked without being implemented. I’m really confused. Could anyone help me?
Many methods like complete in class Completer are marked abstract, but in fact It
Share
Yes, this can be a bit confusing. While abstract classes cannot be instantiated, it is possible to make them appear to be instantiable by defining a factory constructor. This is what
Completer,Futureand other abstract classes do:You can then invoke methods on the object created by the
factoryconstructor. In the example above,factory Completer()returns a new_CompleterImplobject. Look at the (truncated) code of that class:and you see
complete(); that is the method being invoked.