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