I've looked everywhere and found no solution. I'm wanting to return the result count from a query, yet I'm having troubles. Keep getting "Instance of 'Future" instead of String
I'm using the Singleton pattern.
- DB method (database.dart):
Future<int> getUnCompletedTaskCount () async {
final db = await database;
var result = await db.rawQuery("SELECT * FROM Tasks WHERE isComplete = 0");
int count = Sqflite.firstIntValue(result);
return count;
}
- My method in main.dart:
getResultCount () async {
final value = await DBProvider.db.getUnCompletedTaskCount();
return value;
}
- Calling the method by:
getResultCount().toString()
FutureBuilderto fetch data from database, api ,...