first method

Future<ISQLiteItem?> first(
  1. ISQLiteItem item
)

Implementation

Future<ISQLiteItem?> first(ISQLiteItem item) async {
  final db = await getOpenDatabase();
  final tableName = item.getTableName();

  // Query the table to get the very first row
  final List<Map<String, dynamic>> results = await db.rawQuery(
    'SELECT * FROM $tableName LIMIT 1',
  );

  // Return the first item if it exists, otherwise null
  if (results.isNotEmpty) {
    return item.fromMap(results.first);
  }

  return null;
}