Skip to content

Commit ea7354a

Browse files
author
Ivan Dlugos
committed
generated C-API binding - restore backward compatibility with c-api 0.10
1 parent 87fe975 commit ea7354a

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

lib/src/model.dart

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,13 @@ class Model {
4646
}
4747

4848
if (entity.flags != 0) {
49-
_check(bindings.obx_model_entity_flags(_cModel, entity.flags));
49+
// TODO remove try-catch after upgrading to objectbox-c v0.11 where obx_model_entity_flags() exists.
50+
try {
51+
_check(bindings.obx_model_entity_flags(_cModel, entity.flags));
52+
} on ArgumentError {
53+
// flags not supported; don't do anything until objectbox-c v0.11
54+
// this should only be used from our test code
55+
}
5056
}
5157

5258
// add all properties

lib/src/sync.dart

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,9 +220,17 @@ class Sync {
220220
/// Sync() annotation enables synchronization for an entity.
221221
const Sync();
222222

223+
static bool _syncAvailable;
224+
223225
/// Returns true if the loaded ObjectBox native library supports Sync.
224226
static bool isAvailable() {
225-
return bindings.obx_sync_available() != 0;
227+
// TODO remove try-catch after upgrading to objectbox-c v0.11 where obx_sync_available() exists.
228+
try {
229+
_syncAvailable ??= bindings.obx_sync_available() != 0;
230+
} on ArgumentError {
231+
_syncAvailable = false;
232+
}
233+
return _syncAvailable;
226234
}
227235

228236
/// Creates a sync client associated with the given store and configures it with the given options.

0 commit comments

Comments
 (0)