getValue<T> method

T? getValue<T>(
  1. String fieldName
)

Implementation

T? getValue<T>(String fieldName) {
  if (!fields.containsKey(fieldName)) {
    return null;
  }

  final value = fields[fieldName];
  if (value == null) {
    return null;
  }

  try {
    final afterCast = value as T;
    return afterCast;
  } catch (e) {
    throw FieldTypeMismatchException(
        'Field "$fieldName" could not be cast to the expected type: ${e.toString()}');
  }
}