setPropertyUnsafeIfNotDefault<T> method
Set property if not equal to the default value.
- This is useful for preventing default state from bloating saved JSON models.
- Object must implement == as value equality.
Implementation
void setPropertyUnsafeIfNotDefault<T>(String property, T? defaultValue, T? value)
{
if (value != null &&
value != defaultValue) {
setPropertyUnsafe(property, value);
}
else {
removeProperty(property);
}
}