Skip to content

Commit 29aee94

Browse files
Merge pull request #428 from objectbox/add-admin-to-example
Add Admin to relations demo
2 parents 3e1761d + 25621a2 commit 29aee94

File tree

4 files changed

+28
-0
lines changed

4 files changed

+28
-0
lines changed

dev-doc/updating-c-library.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ Update `flutter_libs` and `sync_flutter_libs` with **compatible library versions
1818
- Shortcut: search and replace `-android:3.1.3` in `build.gradle` files.
1919
- In [flutter_libs](../flutter_libs/android/build.gradle)
2020
- In [sync_flutter_libs](../sync_flutter_libs/android/build.gradle)
21+
- Android in examples.
22+
- Shortcut: search and replace `-android-objectbrowser:3.1.3` in `build.gradle` files.
23+
- In [objectbox_demo_relations](../objectbox/example/flutter/objectbox_demo_relations/android/app/build.gradle)
2124
- Swift (iOS/macOS) ([view releases](https://github.com/objectbox/objectbox-swift/releases))
2225
- Shortcut: search and replace e.g. `s.dependency 'ObjectBox', '1.7.0` in `.podspec` files.
2326
- In [flutter_libs for iOS](../flutter_libs/ios/objectbox_flutter_libs.podspec)

objectbox/example/flutter/objectbox_demo_relations/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ See how to:
99
- create Boxes and put Objects there ([objectbox.dart](lib/objectbox.dart))
1010
- query for Objects ([objectbox.dart](lib/objectbox.dart))
1111
- create, read, update and delete Objects ([main.dart](lib/main.dart))
12+
- add ObjectBox Admin for debug builds ([objectbox.dart](lib/objectbox.dart), [build.gradle](android/app/build.gradle))
1213

1314
## Docs
1415
- [Getting started with ObjectBox](https://docs.objectbox.io/getting-started)
1516
- [How to use ObjectBox Relations](https://docs.objectbox.io/relations)
17+
- [ObjectBox Admin](https://docs.objectbox.io/data-browser)

objectbox/example/flutter/objectbox_demo_relations/android/app/build.gradle

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,21 @@ flutter {
7070
source '../..'
7171
}
7272

73+
// Optional: add ObjectBox Admin - https://docs.objectbox.io/data-browser
74+
// Tell Gradle to exclude the objectbox-android dependency from debug builds
75+
// that is added by objectbox_flutter_libs. Keeps it for release and profile builds.
76+
configurations {
77+
debugImplementation {
78+
exclude group: 'io.objectbox', module: 'objectbox-android'
79+
}
80+
}
81+
7382
dependencies {
7483
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
84+
85+
// Optional: add ObjectBox Admin - https://docs.objectbox.io/data-browser
86+
// Add objectbox-android-objectbrowser only for debug builds.
87+
// Warning: when objectbox_flutter_libs updates check if version
88+
// needs update, e.g. check https://github.com/objectbox/objectbox-dart/releases.
89+
debugImplementation("io.objectbox:objectbox-android-objectbrowser:3.1.3")
7590
}

objectbox/example/flutter/objectbox_demo_relations/lib/objectbox.dart

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import 'objectbox.g.dart'; // created by `flutter pub run build_runner build`
77
class ObjectBox {
88
/// The Store of this app.
99
late final Store store;
10+
late final Admin _admin;
1011

1112
/// Two Boxes: one for Tasks, one for Tags.
1213
late final Box<Task> taskBox;
@@ -17,6 +18,13 @@ class ObjectBox {
1718
late final Stream<Query<Tag>> tagsStream;
1819

1920
ObjectBox._create(this.store) {
21+
// Optional: enable ObjectBox Admin on debug builds.
22+
// https://docs.objectbox.io/data-browser
23+
if (Admin.isAvailable()) {
24+
// Keep a reference until no longer needed or manually closed.
25+
_admin = Admin(store);
26+
}
27+
2028
taskBox = Box<Task>(store);
2129
tagBox = Box<Tag>(store);
2230

0 commit comments

Comments
 (0)