Code Monkey home page Code Monkey logo

objectbox-dart's Introduction

ObjectBox logo

ObjectBox Dart & Flutter

ObjectBox is a super-fast database storing Dart objects locally.

  • ๐Ÿ High performance - improving response rates and enabling real-time applications.
  • ๐Ÿช‚ ACID compliance - Atomic, Consistent, Isolated, Durable.
  • ๐Ÿ”— Relations - object links / relationships are built-in.
  • ๐ŸŒฑ Scalable - grows with your app, handling millions of objects with ease.
  • ๐Ÿ’ Queries - filter data as needed, even across relations.
  • ๐Ÿฆฎ Statically typed - compile time checks & optimizations.
  • ๐Ÿ’ป Multiplatform - Android, iOS, macOS, Linux, Windows.
  • ๐Ÿ“ƒ Schema migration - change your model with confidence.
  • ๐Ÿ‘ฅ ObjectBox Sync - keeps data in sync offline or online, between devices and servers.

Sneak peek

@Entity()
class Person {
  int id;

  String firstName;
  String lastName;
}

// Note: in Flutter you also need to specify a directory, see examples.
final store = Store(getObjectBoxModel());
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

// find all people whose name start with letter 'J'
final query = box.query(Person_.firstName.startsWith('J')).build();
final people = query.find();  // find() returns List<Person>

Head over to examples for more.

Getting started

Add the following dependencies to start using ObjectBox and code generator.

Flutter mobile apps

dependencies:
  objectbox: ^0.12.1
  objectbox_flutter_libs: any

dev_dependencies:
  build_runner: ^1.0.0
  objectbox_generator: any
  • Install the packages: flutter pub get
  • XCode/iOS: under Architectures replace ${ARCHS_STANDARD) with arm64 (or $ARCHS_STANDARD_64_BIT). See FAQ for details.

Dart CLI apps or Flutter desktop apps

dependencies:
  objectbox: ^0.12.1

dev_dependencies:
  build_runner: ^1.0.0
  objectbox_generator: any
  • Install the packages: (flutter|dart) pub get

  • Install objectbox-c system-wide (use "Git bash" on Windows):

    bash <(curl -s https://raw.githubusercontent.com/objectbox/objectbox-dart/main/install.sh)
  • macOS: dart might later complain that it cannot find the libobjectbox.dylib. You probably have to unsign the dart binary - see this dart issue for details.

  • Windows: copy the downloaded lib/objectbox.dll to C:\Windows\System32\ (requires admin privileges).

Help wanted

ObjectBox Dart is still not on par with other language bindings where ObjectBox is available. To bring all the missing features to Dart, we're asking the community to help out. PRs are more than welcome! The ObjectBox team will try its best to guide you and answer questions.

Feedback

Also, please let us know your feedback GitHub issues, either comment on an existing one or open a new one. For example, if you experience errors or if you have ideas for how to improve the API. Thanks!

FAQ

Q: After adding ObjectBox, the size of the APK increased significantly. Why is that?
A: Flutter compresses its native libraries (.so files) by default in the APK. ObjectBox instructs the Android build to use uncompressed native libraries instead (following the official Android recommendations). This setting affects the Flutter native libraries as well. Thus the now uncompressed Flutter libraries add to the APK size as well; we've seen an additional 19 MB for the standard Flutter libraries. This is bad, right? Nope, actually uncompressed libraries use less storage space on device and have other advantages. For details, please review the official Android recommendations and the ObjectBox FAQ entry on this. Both links also explain how to force compression using android:extractNativeLibs="true".

Q: Flutter iOS builds for armv7 fail with "ObjectBox does not contain that architecture", does it not support 32-bit devices?
A: No, only 64-bit iOS devices are supported. When ObjectBox was first released for iOS all the latest iOS devices had 64-bit support, so we decided to not ship armv7 support. To resolve the build error, in your XCode project look under Architectures and replace ${ARCHS_STANDARD) with arm64 (or $ARCHS_STANDARD_64_BIT).

See also

License

Copyright 2020 ObjectBox Ltd. All rights reserved.

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.

objectbox-dart's People

Contributors

vaind avatar nalenz-objectbox avatar buggaboo avatar greenrobot-team avatar liquidiert avatar greenrobot avatar gregorysech avatar randomdalek avatar rtrackerdev avatar theimpulson avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.