when I fetch data from firebase
I got these errors like
why list dynamic could change into String type ?
type 'List<dynamic>' is not a subtype of type 'List<String>
I put the code below it. the loaded product does not contain items
Future<void> fetchandSetProduct() async {
final url =
Uri.https('cakejaffna-default-rtdb.firebaseio.com', '/cakelist.json');
try {
final response = await http.get(url);
print(response.statusCode);
final extractData = json.decode(response.body) as Map<String, dynamic>;
final List<Cake> loadedProduct = [];
print(extractData);
extractData.forEach((cakeId, cakeData) {
loadedProduct.add(Cake(
id: cakeId,
imageUrl: cakeData['imageUrl'],
title: cakeData['title'],
hotelName: cakeData['hotelName'],
rating: cakeData['rating'],
ratecount: cakeData['ratecount'],
amount: cakeData['amount'],
details: cakeData['details'],
categories: cakeData['categories']));
});
_cakeList = loadedProduct ;
notifyListeners();
} catch (error) {
print(error);
print("relly error");
}
}