[英]Why stateful/stateless widgets extends and doesn't implements?
I have this question for a job interview, and i want to know why the stateful and staless widgets, use extends and why not use implements in Flutter/Dart?我有一个求职面试的问题,我想知道为什么有状态和无状态的小部件使用扩展,为什么不在 Flutter/Dart 中使用工具?
extends
is usually the go-to when you want to make a more specific version of a class.当您想要制作更具体的 class 版本时,
extends
通常是首选。
When you extend a class, you inherit all properties, methods, etc. If you want to override a method, you prefix the method with @override
.当你扩展一个 class 时,你继承了所有的属性、方法等。如果你想覆盖一个方法,你可以在方法前面加上
@override
。
implements
is when you want to make a whole new version of a class but you want to inherit the class type. implements
是当您想要制作 class 的全新版本但您想要继承 class 类型时。
When you create a new implementation of a class, you are responsible for supplying everything necessary to make that class function.当您创建 class 的新实现时,您有责任提供制作 class function 所需的一切。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.