initDb function Null safety Utils
Initialize and return the database
Implementation
Future<Database> initDb() async {
const dbName = 'easymoney.db';
final databasesPath = await getDatabasesPath();
final dbPath = join(databasesPath, dbName);
try {
await Directory(databasesPath).create(recursive: true);
} catch (_) {}
final db = await openDatabase(
dbPath,
onConfigure: _onConfigure,
onCreate: _onCreate,
version: 1,
singleInstance: true,
);
return db;
}