Skip to content

Commit 32a1770

Browse files
committed
Implemented base Drift schemas
1 parent fe58113 commit 32a1770

20 files changed

+4883
-0
lines changed

.vscode/settings.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"yaml.schemas": {
3+
"https://json.schemastore.org/dart-build": [
4+
"build.yaml",
5+
"*.build.yaml",
6+
"build.*.yaml"
7+
]
8+
}
9+
}

build.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
targets:
2+
$default:
3+
builders:
4+
drift_dev:
5+
enabled: false
6+
drift_dev:analyzer:
7+
enabled: true
8+
options: &options
9+
named_parameters: true
10+
store_date_time_values_as_text: true
11+
drift_dev:modular:
12+
enabled: true
13+
options: *options

example/android/app/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ android {
2626
targetSdk = flutter.targetSdkVersion
2727
versionCode = flutter.versionCode
2828
versionName = flutter.versionName
29+
abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86_64'
2930
}
3031

3132
buildTypes {
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
// Copyright © Luka S (JaffaKetchup) under GPL-v3
2+
// A full license can be found at .\LICENSE
3+
4+
import 'dart:async';
5+
import 'dart:collection';
6+
import 'dart:convert';
7+
import 'dart:io';
8+
import 'dart:isolate';
9+
import 'dart:math';
10+
11+
import 'package:collection/collection.dart';
12+
import 'package:flutter/material.dart';
13+
import 'package:flutter/services.dart';
14+
import 'package:meta/meta.dart';
15+
import 'package:path/path.dart' as path;
16+
import 'package:path_provider/path_provider.dart';
17+
18+
import '../../../../../../flutter_map_tile_caching.dart';
19+
import '../../../../../misc/int_extremes.dart';
20+
import '../../../../export_internal.dart';
21+
import '../models/generated/objectbox.g.dart';
22+
import '../models/src/recovery.dart';
23+
import '../models/src/recovery_region.dart';
24+
import '../models/src/root.dart';
25+
import '../database/models/store.dart';
26+
import '../models/src/tile.dart';
27+
28+
export 'package:objectbox/objectbox.dart' show StorageException;
29+
30+
part 'internal_workers/standard/cmd_type.dart';
31+
part 'internal_workers/standard/worker.dart';
32+
part 'internal_workers/shared.dart';
33+
part 'internal_workers/thread_safe.dart';
34+
part 'internal.dart';
35+
36+
/// Implementation of [FMTCBackend] that uses ObjectBox as the storage database
37+
///
38+
/// On web, this redirects to a no-op implementation that throws
39+
/// [UnsupportedError]s when attempting to use [initialise] or [uninitialise],
40+
/// and [RootUnavailable] when trying to use any other method.
41+
final class FMTCObjectBoxBackend implements FMTCBackend {
42+
/// {@macro fmtc.backend.initialise}
43+
///
44+
/// ---
45+
///
46+
/// [maxDatabaseSize] is the maximum size the database file can grow
47+
/// to, in KB. Exceeding it throws [DbFullException] (from
48+
/// 'package:objectbox') on write operations. Defaults to 10 GB (10000000 KB).
49+
///
50+
/// [macosApplicationGroup] should be set when creating a sandboxed macOS app,
51+
/// specify the application group (of less than 20 chars). See
52+
/// [the ObjectBox docs](https://docs.objectbox.io/getting-started) for
53+
/// details.
54+
///
55+
/// [rootIsolateToken] should only be used in exceptional circumstances where
56+
/// this backend is being initialised in a seperate isolate (or background)
57+
/// thread.
58+
///
59+
/// Avoid using [useInMemoryDatabase] outside of testing purposes.
60+
@override
61+
Future<void> initialise({
62+
String? rootDirectory,
63+
int maxDatabaseSize = 10000000,
64+
String? macosApplicationGroup,
65+
RootIsolateToken? rootIsolateToken,
66+
@visibleForTesting bool useInMemoryDatabase = false,
67+
}) =>
68+
FMTCObjectBoxBackendInternal._instance.initialise(
69+
rootDirectory: rootDirectory,
70+
maxDatabaseSize: maxDatabaseSize,
71+
macosApplicationGroup: macosApplicationGroup,
72+
useInMemoryDatabase: useInMemoryDatabase,
73+
rootIsolateToken: rootIsolateToken,
74+
);
75+
76+
/// {@macro fmtc.backend.uninitialise}
77+
///
78+
/// If [immediate] is `true`, any operations currently underway will be lost,
79+
/// as the worker will be killed as quickly as possible (not necessarily
80+
/// instantly).
81+
/// If `false`, all operations currently underway will be allowed to complete,
82+
/// but any operations started after this method call will be lost.
83+
@override
84+
Future<void> uninitialise({
85+
bool deleteRoot = false,
86+
bool immediate = false,
87+
}) =>
88+
FMTCObjectBoxBackendInternal._instance
89+
.uninitialise(deleteRoot: deleteRoot, immediate: immediate);
90+
}

0 commit comments

Comments
 (0)