Skip to content

Commit

Permalink
🚧🍃 Switch to sqflite, got my linux env fixed!
Browse files Browse the repository at this point in the history
  • Loading branch information
MulverineX committed Sep 8, 2023
1 parent e05ab95 commit 7ad069c
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 50 deletions.
16 changes: 13 additions & 3 deletions packages/client-flutter/lib/app/load_core.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'dart:async';
import 'dart:convert';
import 'dart:io';

import 'package:sqlite3/sqlite3.dart';
import 'package:sqflite_common_ffi/sqflite_ffi.dart';
import 'package:path/path.dart';
import 'package:path_provider/path_provider.dart';
import 'package:http/http.dart' as http;
Expand All @@ -11,7 +11,17 @@ import 'package:flutter_js/flutter_js.dart';
Future<void> load() async {
final appData = (await getApplicationSupportDirectory()).path;

final db = sqlite3.open(join(appData, 'main.db'));
if (Platform.isWindows || Platform.isLinux) {
// Initialize FFI
sqfliteFfiInit();
}
// Change the default factory. On iOS/Android, if not using `sqlite_flutter_lib` you can forget
// this step, it will use the sqlite version available on the system.
databaseFactory = databaseFactoryFfi;

final db = await openDatabase(join(appData, 'main.db'));

// TODO: Add ability to run Refracture offline

const basePath = 'https://github.com/refracturemedia/refracture-music/releases/latest/download';

Expand Down Expand Up @@ -60,7 +70,7 @@ Future<void> load() async {
initDatabase();

core.onMessage('queryDatabase', (query) {
return db.select(query);
return db.query(query);
});

print(core);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include <bitsdojo_window_linux/bitsdojo_window_plugin.h>
#include <flutter_acrylic/flutter_acrylic_plugin.h>
#include <flutter_js/flutter_js_plugin.h>
#include <sqlite3_flutter_libs/sqlite3_flutter_libs_plugin.h>

void fl_register_plugins(FlPluginRegistry* registry) {
g_autoptr(FlPluginRegistrar) bitsdojo_window_linux_registrar =
Expand All @@ -21,7 +20,4 @@ void fl_register_plugins(FlPluginRegistry* registry) {
g_autoptr(FlPluginRegistrar) flutter_js_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "FlutterJsPlugin");
flutter_js_plugin_register_with_registrar(flutter_js_registrar);
g_autoptr(FlPluginRegistrar) sqlite3_flutter_libs_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "Sqlite3FlutterLibsPlugin");
sqlite3_flutter_libs_plugin_register_with_registrar(sqlite3_flutter_libs_registrar);
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ list(APPEND FLUTTER_PLUGIN_LIST
bitsdojo_window_linux
flutter_acrylic
flutter_js
sqlite3_flutter_libs
)

list(APPEND FLUTTER_FFI_PLUGIN_LIST
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ import bitsdojo_window_macos
import flutter_js
import macos_window_utils
import path_provider_foundation
import sqlite3_flutter_libs
import sqflite

func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
BitsdojoWindowPlugin.register(with: registry.registrar(forPlugin: "BitsdojoWindowPlugin"))
FlutterJsPlugin.register(with: registry.registrar(forPlugin: "FlutterJsPlugin"))
MacOSWindowUtilsPlugin.register(with: registry.registrar(forPlugin: "MacOSWindowUtilsPlugin"))
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
Sqlite3FlutterLibsPlugin.register(with: registry.registrar(forPlugin: "Sqlite3FlutterLibsPlugin"))
SqflitePlugin.register(with: registry.registrar(forPlugin: "SqflitePlugin"))
}
69 changes: 36 additions & 33 deletions packages/client-flutter/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ packages:
dependency: transitive
description:
name: archive
sha256: "0c8368c9b3f0abbc193b9d6133649a614204b528982bebc7026372d61677ce3a"
sha256: "49b1fad315e57ab0bbc15bcbb874e83116a1d78f77ebd500a4af6c9407d6b28e"
url: "https://pub.dev"
source: hosted
version: "3.3.7"
version: "3.3.8"
args:
dependency: transitive
description:
Expand Down Expand Up @@ -203,19 +203,6 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
flutter_web_plugins:
dependency: transitive
description: flutter
source: sdk
version: "0.0.0"
go_router:
dependency: "direct main"
description:
name: go_router
sha256: "5668e6d3dbcb2d0dfa25f7567554b88c57e1e3f3c440b672b24d4a9477017d5b"
url: "https://pub.dev"
source: hosted
version: "10.1.2"
google_fonts:
dependency: "direct main"
description:
Expand Down Expand Up @@ -280,22 +267,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.1.1"
logging:
dependency: transitive
description:
name: logging
sha256: "623a88c9594aa774443aa3eb2d41807a48486b5613e67599fb4c41c0ad47c340"
url: "https://pub.dev"
source: hosted
version: "1.2.0"
macos_window_utils:
dependency: transitive
description:
name: macos_window_utils
sha256: "43a90473f8786f00f07203e6819dab67e032f8896dafa4a6f85fbc71fba32c0b"
sha256: c51aba4b8517d1b3dc3d3b0653eff4f84f318040d0f01ea0da4e64298ac76024
url: "https://pub.dev"
source: hosted
version: "1.2.0"
version: "1.3.0"
matcher:
dependency: transitive
description:
Expand Down Expand Up @@ -421,22 +400,38 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.10.0"
sqlite3:
sqflite:
dependency: "direct main"
description:
name: sqlite3
sha256: db65233e6b99e99b2548932f55a987961bc06d82a31a0665451fa0b4fff4c3fb
name: sqflite
sha256: "591f1602816e9c31377d5f008c2d9ef7b8aca8941c3f89cc5fd9d84da0c38a9a"
url: "https://pub.dev"
source: hosted
version: "2.1.0"
sqlite3_flutter_libs:
version: "2.3.0"
sqflite_common:
dependency: transitive
description:
name: sqflite_common
sha256: "1b92f368f44b0dee2425bb861cfa17b6f6cf3961f762ff6f941d20b33355660a"
url: "https://pub.dev"
source: hosted
version: "2.5.0"
sqflite_common_ffi:
dependency: "direct main"
description:
name: sqlite3_flutter_libs
sha256: fb115050b0c2589afe2085a62d77f5deda4db65db20a5c65a6e0c92fda89b45e
name: sqflite_common_ffi
sha256: "0d5cc1be2eb18400ac6701c31211d44164393aa75886093002ecdd947be04f93"
url: "https://pub.dev"
source: hosted
version: "0.5.16"
version: "2.3.0+2"
sqlite3:
dependency: transitive
description:
name: sqlite3
sha256: db65233e6b99e99b2548932f55a987961bc06d82a31a0665451fa0b4fff4c3fb
url: "https://pub.dev"
source: hosted
version: "2.1.0"
stack_trace:
dependency: transitive
description:
Expand Down Expand Up @@ -469,6 +464,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.3.1"
synchronized:
dependency: transitive
description:
name: synchronized
sha256: "5fcbd27688af6082f5abd611af56ee575342c30e87541d0245f7ff99faa02c60"
url: "https://pub.dev"
source: hosted
version: "3.1.0"
term_glyph:
dependency: transitive
description:
Expand Down
5 changes: 2 additions & 3 deletions packages/client-flutter/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,12 @@ dependencies:
just_the_tooltip: ^0.0.12
google_fonts: ^5.1.0
flutter_staggered_grid_view: ^0.7.0
go_router: ^10.0.0
sqlite3: ^2.1.0
path: ^1.8.3
path_provider: ^2.1.1
http: ^1.1.0
flutter_js: ^0.8.0
sqlite3_flutter_libs: ^0.5.16
sqflite_common_ffi: ^2.3.0+2
sqflite: ^2.3.0

dev_dependencies:
flutter_test:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include <bitsdojo_window_windows/bitsdojo_window_plugin.h>
#include <flutter_acrylic/flutter_acrylic_plugin.h>
#include <flutter_js/flutter_js_plugin.h>
#include <sqlite3_flutter_libs/sqlite3_flutter_libs_plugin.h>

void RegisterPlugins(flutter::PluginRegistry* registry) {
BitsdojoWindowPluginRegisterWithRegistrar(
Expand All @@ -18,6 +17,4 @@ void RegisterPlugins(flutter::PluginRegistry* registry) {
registry->GetRegistrarForPlugin("FlutterAcrylicPlugin"));
FlutterJsPluginRegisterWithRegistrar(
registry->GetRegistrarForPlugin("FlutterJsPlugin"));
Sqlite3FlutterLibsPluginRegisterWithRegistrar(
registry->GetRegistrarForPlugin("Sqlite3FlutterLibsPlugin"));
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ list(APPEND FLUTTER_PLUGIN_LIST
bitsdojo_window_windows
flutter_acrylic
flutter_js
sqlite3_flutter_libs
)

list(APPEND FLUTTER_FFI_PLUGIN_LIST
Expand Down

0 comments on commit 7ad069c

Please sign in to comment.