Box<T> class Null safety

A Box instance gives you access to objects of a particular type. You get Box instances via or Box(Store).

For example, if you have User and Order entities, you need two Box objects to interact with them:

Box<User> userBox =;
Box<Order> orderBox =;


Box(Store store)
Create a box for an Entity.


hashCode int
The hash code for this object. [...]
read-only, inherited
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited


contains(int id) bool
Returns true if this box contains an Object with the ID id.
containsMany(List<int> ids) bool
Returns true if this box contains objects with all of the given ids.
count({int limit = 0}) int
Returns the count of all stored Objects in this box. If limit is not zero, stops counting at the given limit.
get(int id) → T?
Retrieves the stored object with the ID id from this box's database. Returns null if an object with the given ID doesn't exist.
getAll() List<T>
Returns all stored objects in this Box.
getMany(List<int> ids, {bool growableResult = false}) List<T?>
Returns a list of ids.length Objects of type T, each corresponding to the location of its ID in ids. Non-existent IDs become null. [...]
isEmpty() bool
Returns true if no objects are in this box.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
put(T object, {PutMode mode = PutMode.put}) int
Puts the given Object in the box (aka persisting it). [...]
putAsync(T object, {PutMode mode = PutMode.put}) Future<int>
Puts the given object in the box (persisting it) asynchronously. [...]
putMany(List<T> objects, {PutMode mode = PutMode.put}) List<int>
Puts the given objects into this Box in a single transaction. [...]
putQueued(T object, {PutMode mode = PutMode.put}) int
Schedules the given object to be put later on, by an asynchronous queue. [...]
query([Condition<T>? qc]) QueryBuilder<T>
Returns a builder to create queries for Object matching supplied criteria.
remove(int id) bool
Removes (deletes) the Object with the given id. Returns true if the object was present (and thus removed), otherwise returns false.
removeAll() int
Removes (deletes) ALL Objects in a single transaction.
removeMany(List<int> ids) int
Removes (deletes) by ID, returning a list of IDs of all removed Objects.
toString() String
A string representation of this object. [...]


operator ==(Object other) bool
The equality operator. [...]