LazyDatabase constructor

LazyDatabase(
  1. DatabaseOpener opener, {
  2. SqlDialect dialect = SqlDialect.sqlite,
  3. bool openImmediately = false,
})

Declares a LazyDatabase that will run opener when the database is first requested to be opened. You must specify the same dialect as the underlying database has.

If openImmediately is true (it's false by default), the database calls opener immediately. This can be useful when opener captures an existing future or other state, as close would otherwise not clean up if the database has never been used.

Implementation

LazyDatabase(this.opener,
    {SqlDialect dialect = SqlDialect.sqlite, bool openImmediately = false})
    : _dialect = dialect {
  if (openImmediately) {
    unawaited(_awaitOpened());
  }
}