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 = _realm.handle.find(metadata.classKey, primaryKey);
  if (handle == null) {
    return null;
  }

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