set<V> method
void
set<V>(
- V? value
Sets the field value
.
If value
is null uses defaultValue.
Applies filter if exists and value
is not null.
Implementation
void set<V>(V? value) {
if (value == null) {
_value = defaultValue;
} else {
if (filter != null) {
_value = filter!(value) ?? defaultValue;
} else {
try {
_value = value as T;
} catch (e) {
if (_value is int) {
_value = parseInt(value) as T;
} else if (_value is double) {
_value = parseDouble(value) as T;
} else if (_value is num) {
_value = parseNum(value) as T;
} else if (_value is bool) {
_value = parseBool(value) as T;
} else if (_value is String) {
_value = parseString(value) as T;
} else {
rethrow;
}
}
}
}
}