handleStringType<T> function

T? handleStringType<T>(
  1. dynamic result,
  2. String propertyName
)

Helper method for handling different string types, based on the document information source.

Implementation

T? handleStringType<T>(dynamic result, String propertyName) {
  if (result == null) return null;

  if (T == String) {
    if (result is Map && result[propertyName] is String) {
      return result[propertyName] as T;
    }
    return null;
  }

  if (T == StringResult) {
    final value = result[propertyName];
    if (value is Map<String, dynamic>) {
      return StringResult(value) as T;
    }
    return null;
  }

  return null;
}