RealmValue class

A type that can represent any valid realm data type, except collections and embedded objects.

You can use RealmValue to declare fields on realm models, in which case it must be non-nullable, but it can wrap a null-value. List of RealmValue (List<RealmValue>) are also legal.

RealmValue fields can be Indexed

@RealmModel()
class _AnythingGoes {
  @Indexed()
  late RealmValue any;
  late List<RealmValue> manyAny;
}

void main() {
  final realm = Realm(Configuration.local([AnythingGoes.schema]));
  realm.write(() {
    final something = realm.add(AnythingGoes(any: RealmValue.string('text')));
    something.manyAny.addAll([
      null,
      true,
      'text',
      42,
      3.14,
    ].map(RealmValue.from));
  });
}

Constructors

RealmValue.bool(bool b)
const
RealmValue.dateTime(DateTime timestamp)
const
RealmValue.decimal128(Decimal128 decimal)
const
RealmValue.double(double d)
const
RealmValue.from(Object? o)
Will throw ArgumentError
factory
RealmValue.int(int i)
const
RealmValue.nullValue()
const
RealmValue.objectId(ObjectId id)
const
RealmValue.realmObject(RealmObjectMarker o)
const
RealmValue.string(String text)
const
RealmValue.uuid(Uuid uuid)
const

Properties

hashCode int
The hash code for this object.
no setteroverride
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
type Type
no setter
value Object?
final

Methods

as<T>() → T
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
override

Operators

operator ==(Object? other) bool
The equality operator.
override