我搞不懂我们为什么需要工具?根据这https://dart.dev/language/classes#implicit-interfaces条 在我们使用了实现之后,我们应该重写父类中除了构造函数之外的所有内容.
// A person. The implicit interface contains greet().
class Person {
// In the interface, but visible only in this library.
final String _name;
// Not in the interface, since this is a constructor.
Person(this._name);
// In the interface.
String greet(String who) => 'Hello, $who. I am $_name.';
}
// An implementation of the Person interface.
class Impostor implements Person {
String get _name => '';
String greet(String who) => 'Hi $who. Do you know who I am?';
}
所以我的问题是,为什么我们不能只创建一个新类,而不是使用工具呢?