Skip to content

Commit

Permalink
attempt to fix on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
frank06 committed Apr 30, 2024
1 parent c53bbea commit 18ca74e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/flutter_data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ library flutter_data;
// import external packages
import 'dart:async';
import 'dart:convert';
import 'dart:ffi';
import 'dart:io';
import 'dart:isolate';
import 'dart:math' show Random;
Expand All @@ -15,6 +16,7 @@ import 'package:inflection3/inflection3.dart' as inflection;
import 'package:meta/meta.dart';
import 'package:path/path.dart' as path_helper;
import 'package:riverpod/riverpod.dart';
import 'package:sqlite3/open.dart';
import 'package:sqlite3/sqlite3.dart';
import 'package:state_notifier/state_notifier.dart';

Expand Down
13 changes: 13 additions & 0 deletions lib/src/storage/local_storage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ class LocalStorage {
await destroy();
}

if (Platform.isWindows) {
open.overrideFor(OperatingSystem.windows, _openOnWindows);
}

db = sqlite3.open(path, mutex: false);

if (inIsolate) {
Expand Down Expand Up @@ -109,3 +113,12 @@ enum LocalStorageClearStrategy {
final localStorageProvider = Provider<LocalStorage>(
(ref) => LocalStorage(baseDirFn: () => ''),
);

// platforms

DynamicLibrary _openOnWindows() {
final scriptDir = File(Platform.script.toFilePath()).parent;
final libraryNextToScript =
File(path_helper.join(scriptDir.path, 'sqlite3.dll'));
return DynamicLibrary.open(libraryNextToScript.path);
}

0 comments on commit 18ca74e

Please sign in to comment.