get<T> method

T? get<T>(
  1. String key, {
  2. T? defaultValue,
})

Get a value of type T associated with a given key

Returns null or defaultValue if provided.

Implementation

T? get<T>(String key, {T? defaultValue}) {
  if (_getObjectData().containsKey(key)) {
    final result = _getObjectData()[key];

    if (result is _Valuable) {
      return result.getValue() as T?;
    }

    if (result is _ParseRelation) {
      return (result
        ..parent = (this as ParseObject)
        ..key = key) as T?;
    }

    return result as T?;
  } else {
    return defaultValue;
  }
}