open static method
Opens a database file.
The vfs option can be used to set the appropriate virtual file system
implementation. When null, the default file system will be used.
If uri is enabled (defaults to false), the filename will be
interpreted as an uri as according to https://www.sqlite.org/uri.html.
If the mutex parameter is set to true, the SQLITE_OPEN_FULLMUTEX flag
will be set. If it's set to false, SQLITE_OPEN_NOMUTEX will be enabled.
By default, neither parameter will be set.
Implementation
static Future<AsyncDatabase> open(
String filename, {
String? vfs,
OpenMode mode = OpenMode.readWriteCreate,
bool uri = false,
bool? mutex,
}) async {
//PrintAppender.setupLogging(level: Level.INFO);
var receivePort = ReceivePort();
//var token = RootIsolateToken.instance;
var worker = await Isolate.spawn(
_executeCommand,
AsyncDatabaseCommand(
"_init",
receivePort.sendPort,
));
AsyncDatabaseCommand response = await receivePort.first;
var workerPort = response.sendPort;
var asyncDatabase = AsyncDatabase._(worker, workerPort);
await asyncDatabase.sendCommand("open",
body: OpenDatabaseParams(filename, vfs, mode, uri, mutex));
return asyncDatabase;
}