gpt4 book ai didi

dart - 扩展 dart 类类似于 js 原型(prototype)或 swift 扩展

转载 作者:行者123 更新时间:2023-12-03 04:28:20 27 4
gpt4 key购买 nike

扩展提供给我的类(class)。为现有的类提供新功能。或扩展现有的mixin s 或虚拟类,任何东西都可以工作。
也许是这样的:

    class FlatButton {} // maybe not defined by me
mixin on FlatButton {
roundCorner(int pixels) {
//...
}
}

final button = FlatButton();
button.roundCorner(10)

Swift/Kotlin 支持 extension关键字或带有 prototype 的 js .

最佳答案

有一个开放的issue关于这个在 dartlang repo 上。它仍然是开放的,不认为现在是可能的。

关于dart - 扩展 dart 类类似于 js 原型(prototype)或 swift 扩展,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57408429/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com