I need the index number forEach iterable value because I want to update my data table. But for updating the data table I need the column ID. That's why I want the index number for each value and assign it to > i. There are similar questions which was explained how to get the index of iterable. But in my case, I am failed to map the CallLogEntry and that's why I can not able to get the index of this iterable value.
Future callLogDB() async {
Iterable<CallLogEntry> cLog = await CallLog.get();
final dbHelper = DatabaseHelper.instance;
int i = 0;
cLog.forEach((log) async {
i++;
// row to insert
Map<String, dynamic> row = {
//DatabaseHelper.columnId: 2,
DatabaseHelper.columnName: '${log.name}',
DatabaseHelper.columnNumber: '${log.number}',
DatabaseHelper.columnType: '${log.callType}',
DatabaseHelper.columnDate:
'${DateTime.fromMillisecondsSinceEpoch(log.timestamp)}',
DatabaseHelper.columnDuration: '${log.duration}'
};
await dbHelper.insert(row);
print('CallLog $i:: $row');
});
return cLog;
}