mirror of
https://github.com/HendrikRauh/inventree-app.git
synced 2026-01-13 11:36:24 +00:00
Many many changes for null-safety support
This commit is contained in:
parent
2988716bf3
commit
d3eec6a79e
30 changed files with 563 additions and 456 deletions
|
|
@ -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.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue