get method
Retrieves a list of records from the database table.
Optional parameters:
where: A SQL WHERE clause to filter the results.whereArgs: Arguments for the WHERE clause.groupBy: A SQL GROUP BY clause.orderBy: A SQL ORDER BY clause.limit: Limits the number of returned records.
Returns a Future that completes with a list of maps representing the records. Throws an error if the retrieval fails.
Implementation
Future<List<Map<String, dynamic>>> get({
String? where,
List<Object?>? whereArgs,
String? groupBy,
String? orderBy,
int? limit,
}) async {
try {
final db = await database;
final data = await db.query(
_helper.tableName,
where: where,
whereArgs: whereArgs,
groupBy: groupBy,
limit: limit,
orderBy: orderBy,
);
return data;
} catch (e) {
return Future.error("Error in retrieving the data: $e");
}
}