Getters and Setters
get and set make computed properties. A leading underscore makes a member library private.
Example
class Temp {
double _c = 0;
double get f => _c * 9 / 5 + 32;
set f(double v) => _c = (v - 32) * 5 / 9;
}
void main() {
var t = Temp()..f = 212;
print(t._c);
print(t.f);
}Exercise
Computed property.
double area => w * h;
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.