createInBackground static method Null safety

QueryExecutor createInBackground(
  1. File file,
  2. {bool logStatements = false,
  3. DatabaseSetup? setup}

Creates a database storing its result in file.

This method will create the same database as the default constructor of the NativeDatabase class. It also behaves the same otherwise: The file is created if it doesn't exist, logStatements can be used to print statements and setup can be used to perform a one-time setup work when the database is created.

The big distinction of this method is that the database is implicitly created on a background isolate, freeing up your main thread accessing the database from I/O work needed to run statements. When the database returned by this method is closed, the background isolate will shut down as well.

Important limitations: If the setup parameter is given, it must be a static or top-level function. The reason is that it is executed on another isolate.


static QueryExecutor createInBackground(File file,
    {bool logStatements = false, DatabaseSetup? setup}) {
  return createBackgroundConnection(file,
      logStatements: logStatements, setup: setup);