getRelation<T> method

T? getRelation<T>(
  1. String name
)
inherited

Retrieves a cached relation value typed as T.

Returns null if the relation hasn't been loaded or is explicitly null.

Example:

final author = post.getRelation<Author>('author');

Implementation

T? getRelation<T>(String name) {
  final relations = _relationValues[this];
  if (relations == null || !relations.containsKey(name)) {
    return null;
  }
  return relations[name] as T?;
}