open method
Open the database or create a new one.
If supplied the populateFunction
is used.
For sqlite this happens if the db didn't exist, while for postgres the function is executed no matter what, if available.
Implementation
@override
void open({Function? populateFunction}) {
_populateFunction = populateFunction;
bool existsAlready;
if (_dbPath == null) {
_db = sqlite3.openInMemory();
// _db = Database.memory();
existsAlready = false;
} else {
var dbFile = File(_dbPath!);
existsAlready = dbFile.existsSync();
_db = sqlite3.open(_dbPath!);
// _db = Database.openFile(dbFile);
}
_isClosed = false;
if (!existsAlready && populateFunction != null) {
// db is open already, we can use the wrapper for the create function.
populateFunction(this);
}
}