Skip to content

Commit ae6bab7

Browse files
Fix isolate tests on Dart SDK 2.14 and older.
1 parent 4ebfb38 commit ae6bab7

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

objectbox/test/isolates_test.dart

+10-6
Original file line numberDiff line numberDiff line change
@@ -49,20 +49,24 @@ void main() {
4949
/// Work with a single store across multiple isolates using
5050
/// the legacy way of passing a pointer reference to the isolate.
5151
test('single store using reference', () async {
52-
final storeCreator = (dynamic msg) =>
53-
Store.fromReference(getObjectBoxModel(), msg as ByteData);
54-
await testUsingStoreFromIsolate(storeCreator, (env) => env.store.reference);
52+
await testUsingStoreFromIsolate(
53+
storeCreatorFromRef, (env) => env.store.reference);
5554
});
5655

5756
/// Work with a single store across multiple isolates using
5857
/// the directory path to attach to an existing store.
5958
test('single store using attach', () async {
60-
final storeCreator =
61-
(dynamic msg) => Store.attach(getObjectBoxModel(), msg as String);
62-
await testUsingStoreFromIsolate(storeCreator, (env) => env.dir.path);
59+
await testUsingStoreFromIsolate(storeCreatorAttach, (env) => env.dir.path);
6360
});
6461
}
6562

63+
// Note: can't use closures, are only supported from Dart SDK 2.15.
64+
Store storeCreatorFromRef(dynamic msg) =>
65+
Store.fromReference(getObjectBoxModel(), msg as ByteData);
66+
67+
Store storeCreatorAttach(dynamic msg) =>
68+
Store.attach(getObjectBoxModel(), msg as String);
69+
6670
class IsolateInitMessage {
6771
SendPort sendPort;
6872
Store Function(dynamic) storeCreator;

0 commit comments

Comments
 (0)