I TRIED USING MAP TO COLLECT DATA BUT IT DOESN'T WORK EITHER I AM TRYING TO GET LIST OF PRICE FROM REST API USING GETX IN FLUTTER BUT RESULTING TO THE ERROR BELOW SAYING CAST ERROR ON LOADING APP
Asked
Active
Viewed 172 times
-1

K'man Amuda Jr.
- 191
- 1
- 1
- 6
-
1Don't use allCaps, it means shouting. And including from details about question, your api response , model class – Md. Yeasin Sheikh Aug 13 '22 at 06:42
1 Answers
1
You are receiving a map and trying to parse in as a List. Thats what the error is telling you.
I would approach this by creating a model class for the and serialising the data there.
class User {
final String name;
final String email;
User(this.name, this.email);
User.fromJson(Map<String, dynamic> json)
: name = json['name'],
email = json['email'];
Map<String, dynamic> toJson() => {
'name': name,
'email': email,
};
}
example from flutter docs

Adam Maran
- 11
- 1