xxxxxxxxxx
class MyClass {
// Private property
String _myProperty;
// Getter for _myProperty
String get myProperty => _myProperty;
// Setter for _myProperty
set myProperty(String value) {
_myProperty = value;
}
}
void main() {
MyClass myObject = MyClass();
// Accessing the getter
print(myObject.myProperty);
// Modifying the property using the setter
myObject.myProperty = 'New value';
// Accessing the getter again
print(myObject.myProperty);
}