initializeDatabase method
dynamic
initializeDatabase()
Implementation
initializeDatabase() async {
if (databaseFactory != null) {
bool databaseExist = await databaseFactory!.databaseExists(databaseName);
if (databaseExist) {
await databaseFactory?.deleteDatabase(databaseName);
}
return databaseFactory?.openDatabase(databaseName,
options: OpenDatabaseOptions(onConfigure: _onConfigure));
}
Directory documentDirectory = await getApplicationDocumentsDirectory();
String path = join(documentDirectory.path, databaseName + '.db');
var database = inMemory
? await openDatabase(inMemoryDatabasePath, onConfigure: _onConfigure)
: await openDatabase(path,
version: version,
onCreate: _createDatabase,
onConfigure: _onConfigure);
return database;
}