1List to JSON:
2_______________________________________________________________________________
3List<String> fruits = ['Apple', 'Banana', 'Orange', 'Strawberry'];
4String jsonFruits = jsonEncode(fruits);
5
6________________________________________________________________________________
7JSON to List:
8________________________________________________________________________________
9You need to convert each item individually
10
11 var json = jsonEncode(jsonFruits.map((e) => e.toJson()).toList());
12
13or pass an toEncodable function
14
15 var json = jsonEncode(jsonFruits, toEncodable: (e) => e.toJsonAttr());
1List<UserModel> users = (json.decode(response.body) as List)
2 .map((data) => UserModel.fromJson(data))
3 .toList();
4