ifEmpty method

String? ifEmpty(
  1. Function act
)

If the provided String is empty do something.

Example

String foo = '';
foo.ifEmpty(()=>print('String is empty'));

Implementation

String? ifEmpty(Function act) {
  if (this == null) {
    return null;
  }

  return this!.trim().isEmpty ? act() : this;
}