index method
Implementation
Future<ISQLiteItem?> index(ISQLiteItem item, int index) async {
var db = await getOpenDatabase();
// Using LIMIT and OFFSET to get the row at the specified index
var maps = await db.query(
item.getTableName(),
limit: 1, // Limit the query to 1 result
offset: index, // Skip the first 'index' rows to get to the desired row
);
if (maps.isNotEmpty) {
return item
.fromMap(maps.first); // Return the first (and only) matching item
}
return null; // Return null if the index is out of range or no data
}