getById method

  1. @override
Future<T?> getById(
  1. String id
)
override

Retrieves the item with the given id from the local database. Returns null if the item is not found.

Implementation

@override
Future<T?> getById(String id) async {
  final maps = await (database).query(
    tableName,
    where: 'id = ?',
    whereArgs: [id], // Use placeholders for SQL injection prevention
  );
  return maps.isNotEmpty ? fromJson(maps.first) : null;
}