Skip to main content


1. Add dependencies#

First, add Isar to your project. Add the following packages to your pubspec.yaml. Always use the latest version.

isar: any
isar_flutter: any
isar_generator: any
build_runner: any

For non-Flutter projects, you need to manually include the Isar Core binaries.

2. Annotate classes#

Annotate your classes with @Collection and choose an id field.

class Contact {
int? id;
String name;

3. Run code generator#

Execute the following command to start the build_runner:

dart run build_runner build

4. Open Isar instance#

This opens an Isar instance at the default location.

final isar = await openIsar();

5. Write and read from database#

Once your instance is open, you can start using the database.

final contact = Contact() = "My first contact";
await isar.writeTxn((isar) async {
final allContacts = isar.contacts.where().findAll();