find method

RealmObject? find(
  1. String className,
  2. Object primaryKey
)

Fast lookup for a RealmObject of type className with the specified primaryKey.

Implementation

RealmObject? find(String className, Object primaryKey) {
  final metadata = _realm._metadata.getByName(className);

  final handle = realmCore.find(_realm, metadata.classKey, primaryKey);
  if (handle == null) {
    return null;
  }

  final accessor = RealmCoreAccessor(metadata, _realm._isInMigration);
  return RealmObjectInternal.create(RealmObject, _realm, handle, accessor) as RealmObject;
}