计算属性
void main(){
print("主方法被执行了...");
_Rectangle mRectangle = _Rectangle();
mRectangle.width = 10;
mRectangle.height = 20;
print("矩形的面积 == ${mRectangle.area}");
mRectangle.area = 300;
}
class _Rectangle {
num width, height;
num get area {
return width * height;
}
set area(value){
width = value / height;
print("设置完面积后的宽度 == $width");
}
}
最后
以上就是秀丽小猫咪最近收集整理的关于Flutter dart 计算属性的全部内容,更多相关Flutter内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复