queryById method

Future<Map<String, dynamic>?> queryById(
  1. String tableName,
  2. int id
)

Get a specific row by ID

Implementation

Future<Map<String, dynamic>?> queryById(String tableName, int id) async {
  final db = await database;
  final results = await db.query(
    tableName,
    where: 'id = ?',
    whereArgs: [id],
  );
  return results.isNotEmpty ? results.first : null;
}