-
Notifications
You must be signed in to change notification settings - Fork 117
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #86 from objectbox/dev
v0.6.0 Release
- Loading branch information
Showing
91 changed files
with
1,747 additions
and
1,030 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,17 @@ | ||
**/.dart_tool/ | ||
**/.packages | ||
**/build/ | ||
**/.pub/ | ||
**/pubspec.lock | ||
misc/ | ||
**/build/ | ||
|
||
.DS_Store | ||
.idea/ | ||
.vscode/ | ||
|
||
download/ | ||
lib/*.dll | ||
lib/*.dylib | ||
lib/*.so | ||
lib/*.a | ||
.vscode/ | ||
|
||
**/*.g.dart | ||
doc/api |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Contents of this folder is based on `flutter create --template=plugin`. | ||
It was reduced to the minimum that works for library inclusion by client apps. | ||
|
||
Notably, the package depends on `io.objectbox:objectbox-android`, a native ObjectBox library distribution. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
apply plugin: 'com.android.library' | ||
android { | ||
compileSdkVersion 28 | ||
} | ||
|
||
dependencies { | ||
implementation "io.objectbox:objectbox-android:2.5.0" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
rootProject.name = 'objectbox' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="io.objectbox.flutter"> | ||
</manifest> |
4 changes: 4 additions & 0 deletions
4
android/src/main/kotlin/io/objectbox/flutter/ObjectboxPlugin.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package io.objectbox.flutter | ||
|
||
class ObjectboxPlugin { | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,54 @@ | ||
ObjectBox Examples | ||
========================== | ||
|
||
* [Flutter android app](flutter/objectbox_demo) - requires Flutter 1.9 | ||
In the following file, e.g. `models.dart`, we import objectbox.dart to get definitions for `@Entity`, | ||
`@Id` and other annotations and define a single entity that should be persisted by ObjectBox. You could have multiple | ||
entities in the same file or you can have them spread across multiple files in the `lib` directory tree. | ||
|
||
```dart | ||
import "package:objectbox/objectbox.dart"; | ||
@Entity() | ||
class Note { | ||
@Id() // required; stored as a 64-bit unsigned integer in ObjectBox | ||
int id; | ||
String text; | ||
Note({this.text}); // empty default constructor needed but it can have optional args | ||
toString() => "Note{id: $id, text: $text}"; | ||
} | ||
``` | ||
|
||
ObjectBox generator will look for all `@Entity` annotations in your `lib` folder and create a single database definition | ||
`lib/objectbox-model.json` and supporting code in `lib/objectbox.g.dart`. | ||
You should commit `objectbox-model.json` into your source control (e.g. git) and add `objectbox.g.dart` to the ignore | ||
list (e.g. .gitignore), otherwise the build_runner will complain about it being changed each time you pull a change. | ||
|
||
Note: the generator will process `lib` and `test` folders separately and create a separate database in each one, if it | ||
finds annotations there. This is useful if you need a separate test DB, but if you're just writing tests for your own | ||
code you won't have any annotations in the `test` folder so no DB will be created there. | ||
|
||
------------------- | ||
|
||
To use ObjectBox and store the just defined entity, you should import `objectbox.g.dart` and create the `Store`. | ||
Finally, you will create a `Box<Note>` which gives you a typed interface for storing and retrieving `Note` objects. | ||
|
||
```dart | ||
import 'objectbox.g.dart'; // this file will be generated by ObjectBox after running `pub run build_runner build` | ||
void main() { | ||
var store = Store(getObjectBoxModel()); // Note: getObjectBoxModel() is generated for you in objectbox.g.dart | ||
var box = Box<Note>(store); | ||
var note = Note(text: "Hello"); | ||
note.id = box.put(note); | ||
print("new note got id ${note.id}"); | ||
print("refetched note: ${box.get(note.id)}"); | ||
store.close(); | ||
} | ||
``` | ||
|
||
See also | ||
-------- | ||
* sample [Flutter android app](flutter/objectbox_demo) - requires Flutter 1.12 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
example/flutter/objectbox_demo/android/app/src/debug/AndroidManifest.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.