database method

Future<Database> database(
  1. String? pw
)

Database object accessor

Implementation

Future<Database> database(String? pw) async {
  /// If completer is null, database isn't opened, just instantiated
  if (_dbOpenCompleter == null) {
    _dbOpenCompleter = Completer();

    /// This will also complete the db instance
    _openDatabase(pw);
  }

  /// If db is open, the future happens instantly, otherwise, it will wait
  /// for complete to be called below
  return _dbOpenCompleter!.future;
}