extension Extension on Object {
  bool isNullOrEmpty() => this == '' || this == null;

  bool isNullEmptyOrFalse() => this == null || this == '' || this == false;

  bool isNullEmptyZeroOrFalse() =>
      this == null || this == '' || this == 0 || this == false;
}

/// truncate the [String] without cutting words. The length is calculated with the suffix.
extension Truncate on String {
  String truncate(int max, {String suffix = ''}) {
    try {
      return length <= max
          ? this
          : '${substring(0, max - suffix.length)}$suffix';
    } catch (e) {
      return this;
    }
  }
}
