getRelation<T extends ParseObject> method

ParseRelation<T> getRelation<T extends ParseObject>(
  1. String key
)

Get the instance of ParseRelation class associated with the given key

Implementation

ParseRelation<T> getRelation<T extends ParseObject>(String key) {
  final potentialRelation = _getObjectData()[key];

  if (potentialRelation == null) {
    final relation = ParseRelation<T>(parent: this, key: key);

    set(key, relation);

    return relation;
  }

  if (potentialRelation is _ParseRelation<T>) {
    return potentialRelation
      ..parent = this
      ..key = key;
  }

  throw ParseRelationException(
      'The key $key is associated with a value ($potentialRelation) '
      'can not be a relation');
}