void main() {
var rect = Rectangle();
rect.width = 20;
rect.height = 30;
print(rect.area());
}
class Rectangle {
num width, height;
num area() {
return width * height;
}
}
比较
void main() {
var rect = Rectangle();
rect.width = 20;
rect.height = 30;
print(rect.area);
}
class Rectangle {
num width, height;
num get area {
return width * height;
}
}