mirror of https://github.com/AMT-Cheif/drift.git
Fix opening library in encryption example
This commit is contained in:
parent
9c28a06020
commit
a1af6f6114
|
@ -47,7 +47,7 @@ android {
|
|||
applicationId "com.example.drift_encryption_sample"
|
||||
// You can update the following values to match your application needs.
|
||||
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration.
|
||||
minSdkVersion flutter.minSdkVersion
|
||||
minSdkVersion 21
|
||||
targetSdkVersion flutter.targetSdkVersion
|
||||
versionCode flutterVersionCode.toInteger()
|
||||
versionName flutterVersionName
|
||||
|
|
|
@ -26,6 +26,6 @@ subprojects {
|
|||
project.evaluationDependsOn(':app')
|
||||
}
|
||||
|
||||
task clean(type: Delete) {
|
||||
tasks.register("clean", Delete) {
|
||||
delete rootProject.buildDir
|
||||
}
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
import 'dart:ffi';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:drift/drift.dart';
|
||||
import 'package:drift/native.dart';
|
||||
import 'package:path/path.dart' as p;
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
import 'package:sqlcipher_flutter_libs/sqlcipher_flutter_libs.dart';
|
||||
import 'package:sqlite3/open.dart';
|
||||
|
||||
part 'database.g.dart';
|
||||
|
||||
|
@ -39,6 +42,14 @@ QueryExecutor _openDatabase() {
|
|||
|
||||
return NativeDatabase.createInBackground(
|
||||
File(p.join(path.path, 'app.db.enc')),
|
||||
isolateSetup: () async {
|
||||
open
|
||||
..overrideFor(OperatingSystem.android, openCipherOnAndroid)
|
||||
..overrideFor(OperatingSystem.linux,
|
||||
() => DynamicLibrary.open('libsqlcipher.so'))
|
||||
..overrideFor(OperatingSystem.windows,
|
||||
() => DynamicLibrary.open('sqlcipher.dll'));
|
||||
},
|
||||
setup: (db) {
|
||||
// Check that we're actually running with SQLCipher by quering the
|
||||
// cipher_version pragma.
|
||||
|
|
|
@ -1,20 +1,9 @@
|
|||
import 'dart:ffi';
|
||||
|
||||
import 'package:drift/drift.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:sqlite3/open.dart';
|
||||
import 'package:sqlcipher_flutter_libs/sqlcipher_flutter_libs.dart';
|
||||
|
||||
import 'database.dart';
|
||||
|
||||
void main() {
|
||||
open
|
||||
..overrideFor(OperatingSystem.android, openCipherOnAndroid)
|
||||
..overrideFor(
|
||||
OperatingSystem.linux, () => DynamicLibrary.open('libsqlcipher.so'))
|
||||
..overrideFor(
|
||||
OperatingSystem.windows, () => DynamicLibrary.open('sqlcipher.dll'));
|
||||
|
||||
runApp(const MyApp());
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue