In this endpoint http://www.caguascriollos.com/nuevaweb/wp-json/sportspress/v2/tables I'm getting a List of Maps. Inside each element, in the "data" key, I have another List. That List have a "pos" (position) key.
I want to sort each "data" depending on the "pos" value, but I'm getting the following error:
NoSuchMethodError (NoSuchMethodError: Class '_InternalLinkedHashMap<String, dynamic>' has no instance method 'sort'.
Receiver: _LinkedHashMap len:6
Tried calling: sort(LinkedHashSet len:1))
My code:
final response = await http.get(Uri.parse('http://www.caguascriollos.com/nuevaweb/wp-json/sportspress/v2/tables'));
_positions = json.decode(response.body);
for (var _position in _positions!) {
_position['data'].sort({
(a,b) => {
if (a.isInt() && b.isInt()) {
a.toInt().compareTo(b.toInt())
}
}
});
}
from Recent Questions - Stack Overflow https://ift.tt/31v3uUQ
https://ift.tt/eA8V8J
No comments:
Post a Comment