asStrings method

String asStrings(
  1. List<String> keys, [
  2. String? defValue
])

多字段解析Strings

Implementation

String asStrings(List<String> keys, [String? defValue]) {
  if (this == null) return defValue ?? '';
  List<Object>? _values;
  for (String key in keys) {
    Object? value = this![key];
    if (value == null) continue;
    if (value is String) {
      if (value.isEmpty) continue;
      return value;
    } else {
      _values ??= [];
      _values.add(value);
    }
  }
  if (_values != null && _values.isNotEmpty) {
    return _values[0].toString();
  }
  return defValue ?? "";
}