safe method

String safe(
  1. String key, {
  2. String defaultValue = '',
})

Implementation

String safe(String key, {String defaultValue = ''}) {
  if (this[key] != null) {
    final stringValue = this[key].toString();
    if (stringValue.isEmpty || stringValue == 'null') {
      return defaultValue;
    }
    return stringValue;
  }
  return defaultValue;
}