DatabaseTracker constructor
DatabaseTracker()
Creates a new tracker with necessary tables.
If the table exists delete any open connection.
Implementation
DatabaseTracker() {
try {
_db = sqlite3.open(
'file:sqflite_database_tracker?mode=memory&cache=shared',
uri: true,
);
var tableExists = (_db!
.select(
'SELECT COUNT(*) FROM sqlite_master WHERE tbl_name = \'$_tableName\'')
.first
.columnAt(0) as int) >
0;
if (!tableExists) {
_db!.execute(
'''
CREATE TABLE IF NOT EXISTS $_tableName (
$_ptrColName INTEGER NOT NULL PRIMARY KEY
);
''');
} else {
_closeExisting();
}
} catch (e) {
print('error $e creating tracker db');
}
}