Python有可能像使用装饰器@property
的属性一样访问方法。 Dart有这样的事吗?
class Test():
@property
def example():
return "This isn't really a property"
a = new Test()
print a.example
答案 0 :(得分:4)
getters的概念看起来很相似:
class Test {
String get example {
return "This isn't really a property";
}
}
main() {
var a = new Test();
print(a.example);
}