2
0
mirror of https://github.com/inventree/inventree-app.git synced 2025-06-13 10:45:29 +00:00

Many many changes for null-safety support

This commit is contained in:
Oliver
2021-07-09 23:56:38 +10:00
parent 2988716bf3
commit d3eec6a79e
30 changed files with 563 additions and 456 deletions

View File

@ -15,15 +15,19 @@ class InvenTreePreferencesDB {
InvenTreePreferencesDB._();
Completer<Database> _dbOpenCompleter;
Completer<Database> _dbOpenCompleter = Completer();
bool isOpen = false;
Future<Database> get database async {
// If completer is null, AppDatabaseClass is newly instantiated, so database is not yet opened
if (_dbOpenCompleter == null) {
_dbOpenCompleter = Completer();
if (!isOpen) {
// Calling _openDatabase will also complete the completer with database instance
_openDatabase();
isOpen = true;
}
// If the database is already opened, awaiting the future will happen instantly.
// Otherwise, awaiting the returned future will take some time - until complete() is called
// on the Completer in _openDatabase() below.