isNullOrEmptyOrZero method

bool isNullOrEmptyOrZero()

Check null or empty or zero for any type

Implementation

bool isNullOrEmptyOrZero() {
  final value = this;
  if (value == null) return true;

  if (value is String) {
    final trimmed = value.trim();
    // Matches "0", "000", "0.0", "0.00", "00.000", etc.
    return trimmed.isEmpty || RegExp(r'^0+(\.0+)?$').hasMatch(trimmed);
  }

  if (value is num) return value == 0;
  if (value is Iterable) return value.isEmpty;
  if (value is Map) return value.isEmpty;
  return false;
}