Reputation: 9
Future<void> fetchplace() async {
final dataList = await DBHelper.fetchdata('subjects');
List item
_items = dataList
.map(
(item)=> Subjects(item['id'],item['subject'],
item['percentage'],
item['total'],
attend(item['id']),
item['leave'],
item['current'],
item['present'],),
).toList();
notifyListeners();
}
Future<void> attend(String id) async {
final data= await DBHelper.fetchdataattend('data$id',id);
final loc= data.map((e){
return e['attend'];
}).toList();
print(loc);
return loc;
}
It first goes to the fetchplace Function from where it does to the attend function but when it returns the attend variable returns 'Instance To Future'.
Upvotes: 0
Views: 926
Reputation: 109
In dart when u have async function the return type is Future<...> this (...) are the return type of function. In your case u declarate void return (Future< void>), but you are returning "loc" variable. You can switch it to
Future attend(String id) async {
or
Future<dynamic> attend(String id) async {
Upvotes: 1