close method

  1. @override
Future<void> close()
inherited

Closes this database connection and releases all resources associated with it. Implementations should also handle close calls in a state where the database isn't open.

Implementation

@override
Future<void> close() {
  return _openingLock.synchronized(() {
    if (_ensureOpenCalled && !_closed) {
      _closed = true;

      // Make sure the other methods throw an exception when used after
      // close()
      _ensureOpenCalled = false;
      return delegate.close();
    } else {
      // User never attempted to open the database, so this is a no-op.
      return Future.value();
    }
  });
}