can anyone help!! I tried before to put ! before data but it still gives me error and I have another error in the line var keys = value.snapshot.value.keys; it said that The property 'keys' can't be unconditionally accessed because the receiver can be 'null'.
DatabaseReference reference = FirebaseDatabase.instance.reference();
await reference.child('Newss').once().then((value) {
if(value.snapshot.value !=null){
var keys = value.snapshot.value.keys;
var data = value.snapshot.value;
for(var singleValue in keys){
newssData.add(
Newss(
title: data[singleValue]['title'],
image: data[singleValue]['image'],
desc: data[singleValue]['desc'],
));
newssData.reversed.toList();
}
}else{
Fluttertoast.showToast(msg: 'No post uploaded yet');
}
});
return newssData;
}