How do I guarantee a certain named constructor in Dart?
问题 Let us say I have the concrete classes Cat, Dog, and Parrot, and the following interface: class HasGuid { HasGuid.fromId(String id); } My goal is to guarantee that Cat, Dog, and Parrot all have a fromId named constructor. So, I can make calls like: Cat.fromId("Whiskers") =returns> [A Future<Cat> object with id "Whiskers"] Dog.fromId("Fido") =returns> [A Future<Dog> object with id "Fido"] Parrot.fromId("Polly") =returns> [A Future<Parrot> object with id "Poly"] fromId is making a call across