asString method Null safety

String asString(
  1. String key,
  2. [String? defValue]
)

单字段解析

Implementation

String asString(String key, [String? defValue]) {
  if (this == null) return defValue ?? '';
  Object? value = this![key];
  if (value == null) return defValue ?? '';
  if (value is String) return value;
  return value.toString();
}