coalesce<T> method
T
coalesce<T>(
- T defaultValue
replace null with default value
Implementation
T coalesce<T>(T defaultValue) {
if (this is String) {
String? str = this;
return (str ?? "").isEmpty ? defaultValue : this;
}
return this == null ? defaultValue : this;
}