I have a big list of data represented in a JSON-like object. It's an Iterable<Map<String, dynamic>> acquired from an SQLite database.
Running the query and even filtering the resulting data runs asynchronously, but when I try to map this data into a class, the Main Thread freezes.
The whole block of code is in an async function, and it returns a future of data, but for some reason, toList only runs synchronously.
I tried to use compute, but it keeps saying
Invalid argument(s): Illegal argument in isolate message : (object is a closure - Function '<anonymous closure>':.)
I even tried RxDart's asyncMap, but that didn't seem to work any differently.
Trying to avoid function and use a normal for didn't work either.
What can I do to get the mapping code to run asynchronously?
This is the exact code that has the issue
final filteredCards = cardsRaw.where((e) {
return csvData.any(
(element) =>
e['card_name'] == element.cardName &&
(e['number'] as String).startsWith(element.cardNumber) &&
e['set_name'] == element.setName,
);
}).toList();
cardsRaw is 11k, and csvData is 1000