validate method

String validate([
  1. String value = ''
])

Returns the String if it's not null, otherwise returns the provided default value.

Example:

String? name = null;
print(name.validate("Default")); // "Default"

Implementation

String validate([String value = '']) =>
    this?.trim().isEmptyOrNull ?? true ? value : this!;