Soru/moor
This commit is contained in:
committed by
Christian Pauly
parent
226705be2a
commit
782c849772
12
lib/utils/database/mobile.dart
Normal file
12
lib/utils/database/mobile.dart
Normal file
@ -0,0 +1,12 @@
|
||||
import 'package:famedlysdk/famedlysdk.dart';
|
||||
import 'package:encrypted_moor/encrypted_moor.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
Database constructDb({bool logStatements = false, String filename = 'database.sqlite', String password = ''}) {
|
||||
debugPrint('[Moor] using encrypted moor');
|
||||
return Database(EncryptedExecutor(path: filename, password: password, logStatements: logStatements));
|
||||
}
|
||||
|
||||
Future<String> getLocalstorage(String key) async {
|
||||
return null;
|
||||
}
|
3
lib/utils/database/shared.dart
Normal file
3
lib/utils/database/shared.dart
Normal file
@ -0,0 +1,3 @@
|
||||
export 'unsupported.dart'
|
||||
if (dart.library.html) 'web.dart'
|
||||
if (dart.library.io) 'mobile.dart';
|
9
lib/utils/database/unsupported.dart
Normal file
9
lib/utils/database/unsupported.dart
Normal file
@ -0,0 +1,9 @@
|
||||
import 'package:famedlysdk/famedlysdk.dart';
|
||||
|
||||
Database constructDb({bool logStatements = false, String filename = 'database.sqlite', String password = ''}) {
|
||||
throw 'Platform not supported';
|
||||
}
|
||||
|
||||
Future<String> getLocalstorage(String key) async {
|
||||
return null;
|
||||
}
|
13
lib/utils/database/web.dart
Normal file
13
lib/utils/database/web.dart
Normal file
@ -0,0 +1,13 @@
|
||||
import 'package:famedlysdk/famedlysdk.dart';
|
||||
import 'package:moor/moor_web.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'dart:html';
|
||||
|
||||
Database constructDb({bool logStatements = false, String filename = 'database.sqlite', String password = ''}) {
|
||||
debugPrint('[Moor] Using moor web');
|
||||
return Database(WebDatabase.withStorage(MoorWebStorage.indexedDbIfSupported(filename), logStatements: logStatements));
|
||||
}
|
||||
|
||||
Future<String> getLocalstorage(String key) async {
|
||||
return await window.localStorage[key];
|
||||
}
|
Reference in New Issue
Block a user