find<T extends RealmObject> method Null safety

T? find<T extends RealmObject>(
  1. Object primaryKey
)

Fast lookup for a RealmObject with the specified primaryKey.

Implementation

T? find<T extends RealmObject>(Object primaryKey) {
  RealmMetadata metadata = _getMetadata(T);

  final handle = realmCore.find(this, metadata.class_.key, primaryKey);
  if (handle == null) {
    return null;
  }

  final accessor = RealmCoreAccessor(metadata);
  var object = RealmObjectInternal.create(T, this, handle, accessor);
  return object as T;
}