Skip to main content

objectbox 6.0.0-rc.1 copy "objectbox: ^6.0.0-rc.1" to clipboard
objectbox: ^6.0.0-rc.1 copied to clipboard

Flutter database for super-fast NoSQL ACID compliant object persistence.

ObjectBox

Getting Started • Documentation • Example Apps • Issues • Blog

Build and test pub.dev package

Flutter database for Dart-native objects and on-device vector management 💙 #

The ObjectBox Flutter database is a great choice for managing Dart objects in cross-platform and AI-driven applications. Its advanced vector search empowers on-device AI for a variety of applications, including RAG AI, generative AI, and similarity searches. Designed for high performance, the ObjectBox Flutter database is excellent for mobile and IoT devices, minimizing CPU, memory, and battery usage to enhance device efficiency and sustainability. As an offline-first solution, ObjectBox makes sure your app reliably works offline as well as online.

Build smarter apps with our easy-to-use native Dart API, and enjoy our seamless Data Sync, which provides data consistency across devices.

Features #

  • 🧠 Artificial Intelligence - superfast on-device vector search.
  • 🏁 Super fast - 10X faster than SQLite - see the performance benchmarks.
  • 🪂 ACID compliant - Atomic, Consistent, Isolated, Durable.
  • 💻 Cross-platform - Android, iOS, macOS, Linux, Windows.
  • 🌱 Scalable - grows with your app, handling millions of objects with ease.
  • 🎯 NoSQL database - no rows or columns, only pure Dart objects.
  • 🔗 Relations - object links / relationships are built-in.
  • 💐 Queries - filter data as needed, even across relations.
  • 📃 Schema migration - simply change your model, we handle the rest.

Oh, and there is one more thing...

😮 Data Sync - sync only when and where needed.

On this page #


Sneak peek - persist Dart objects with ObjectBox #

ObjectBox provides a store with boxes to put objects into:

// Annotate a Dart class to create a Box
@Entity()
class Person {
  @Id()
  int id;
  String firstName;
  String lastName;

  Person({this.id = 0, required this.firstName, required this.lastName});
}

final Store store = await openStore(directory: 'person-db');
final box = store.box<Person>();

var person = Person(firstName: 'Joe', lastName: 'Green');
final id = box.put(person); // Create

person = box.get(id)!;      // Read

person.lastName = 'Black';
box.put(person);            // Update

box.remove(person.id);      // Delete

final query = box           // Query
    .query(Person_.firstName.equals('Joe') & Person_.lastName.startsWith('B'))
    .build();
final List<Person> people = query.find();
query.close();

Getting Started #

Note

Prefer to look at example code? Check out our examples directory.

There are also some video tutorials, each featuring a different example app:

You can add the ObjectBox Dart SDK to

Flutter projects #

To add ObjectBox to your Flutter project:

  1. Run these commands:

    flutter pub add objectbox objectbox_flutter_libs:any
    flutter pub add --dev build_runner objectbox_generator:any
    

    Or to use ObjectBox Sync (requires access to the Sync feature) instead run:

    flutter pub add objectbox objectbox_sync_flutter_libs:any
    flutter pub add --dev build_runner objectbox_generator:any
    
  2. This should add lines like this to your pubspec.yaml:

    dependencies:
      objectbox: ^6.0.0-rc.1
      objectbox_flutter_libs: any
      # If you run the command for ObjectBox Sync it should add instead:
      # objectbox_sync_flutter_libs: any
    
    dev_dependencies:
      build_runner: ^2.4.11
      objectbox_generator: any
    
  3. If you added the above lines manually, then install the packages with flutter pub get.

  4. Your project can now use ObjectBox, continue by defining entity classes.

Note

For iOS apps target at least iOS 15.0: in the ios/Runner.xcodeproj/poject.pbxproj file update IPHONEOS_DEPLOYMENT_TARGET (or open the Runner workspace in Xcode and edit the build setting). In ios/Flutter/AppframeworkInfo.plist, if it's there, update MinimumOSVersion. If still using CocoaPods, in ios/Podfile change the platform.

For macOS apps target at least macOS 12.0: in the macos/Runner.xcodeproj/poject.pbxproj file update MACOSX_DEPLOYMENT_TARGET (or open the Runner workspace in Xcode and edit the build setting). If still using CocoaPods, in macos/Podfile change the platform.

For macOS apps using Sync, make sure entitlements to enable incoming (server) and outgoing connections (client) are added in the macos/Runner/DebugProfile.entitlements and macos/Runner/Release.entitlements files:

<key>com.apple.security.network.server</key>
<true/>
<key>com.apple.security.network.client</key>
<true/>

Note

To run unit tests on your machine, download the latest ObjectBox database library for your system by running this script in your package directory in a bash shell (e.g. Git Bash on Windows):

bash <(curl -s https://raw.githubusercontent.com/objectbox/objectbox-dart/main/install.sh)

To get the variant for ObjectBox Sync, append the --sync argument to the above command.

Dart Native projects #

To add ObjectBox to your Dart Native project:

  1. Run these commands:

    dart pub add objectbox
    dart pub add --dev build_runner objectbox_generator:any
    
  2. This should add lines like this to your pubspec.yaml:

    dependencies:
      objectbox: ^6.0.0-rc.1
    
    dev_dependencies:
      build_runner: ^2.4.11
      objectbox_generator: any
    
  3. If you added the above lines manually, then install the packages with dart pub get

  4. In your package directory, download the ObjectBox C library for your system (on Windows you can use "Git Bash"):

    bash <(curl -s https://raw.githubusercontent.com/objectbox/objectbox-dart/main/install.sh)
    

    Or to use ObjectBox Sync (requires access to the Sync feature) instead run:

    bash <(curl -s https://raw.githubusercontent.com/objectbox/objectbox-dart/main/install.sh) --sync
    
  5. Your project can now use ObjectBox, continue by defining entity classes.

Note

The database library is downloaded into the lib subdirectory of the working directory. It's not necessary to install the library system-wide. This also allows to use different versions for different projects. See the notes on deploying below.

Deploying Dart Native projects

Natively compiled Dart applications that use ObjectBox Dart require a reference to the ObjectBox C library. Hence, the shared library file downloaded with install.sh needs to be shipped with the executable.

The install.sh script downloads the library to the lib subdirectory of the working directory. An executable using ObjectBox Dart looks for the library in this lib directory.

If it is not found there, it falls back to using system directories (using Dart's DynamicLibrary.open):

  • Windows: working directory and %WINDIR%\system32.
  • macOS: /usr/local/lib (and maybe others).
  • Linux: /lib and /usr/lib (again, possibly others).

Flutter Database Performance Benchmarks #

We tested across the four main database operations, CRUD (create, read, update, delete). Each test was run multiple times and executed manually outside of the measured time. Data preparation and evaluation were also done outside of the measured time.

Here are the benchmarks for ObjectBox vs sqflite vs Hive (last updated 2021-09-11) 👇

Bar chart of CRUD objects per second (more is better): ObjectBox is fastest in all four operations, ahead of Hive and far ahead of sqflite

Operation ObjectBox sqflite Hive
Create 472,858 4,415 220,486
Read 1,870,487 47,581 1,645,170
Update 488,048 4,310 108,429
Delete 1,585,791 183,731 364,764

You can run these yourself using our objectbox-dart-performance Flutter benchmark app.

Feedback #

We strive to bring joy to Flutter developers and appreciate any feedback → Please fill in this 2-minute Anonymous Feedback Form.

We are looking forward to your comments and ideas:

Thank you! 🙏

Keep in touch: For general news on ObjectBox, check our blog!

FAQ #

See the FAQ and Troubleshooting pages.

See also #

License #

Copyright © 2019-2026 ObjectBox Ltd. <https://objectbox.io/>

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Note that this license applies to the code in this repository only. See our website on details about all licenses for ObjectBox components.

1.58k
likes
160
points
165k
downloads

Documentation

Documentation
API reference

Publisher

verified publisherobjectbox.io

Weekly Downloads

Flutter database for super-fast NoSQL ACID compliant object persistence.

Homepage
Repository (GitHub)
View/report issues
Contributing

License

Apache-2.0 (license)

Dependencies

collection, ffi, flat_buffers, meta, path

More

Packages that depend on objectbox