I tried to make an app to display images, to do this I am using Firestore, Flutter... to the slider I am using carousel_slider plugin to display those images, but when I recived a new image from Firestore, the slider doesn´t display the new image, but the circle (indicator) display the new circle but doesn´t work too, the indicator works with only the initial images.
my Code the carousel:
_loadCarrouselFood(){
var carouselSlider = CarouselSlider(
viewportFraction: 1.0,
aspectRatio: 2.0,
autoPlay: false,
enlargeCenterPage: true,
items: child,
onPageChanged: (index) {
setState(() {
_current = index;
});
LatLng locationDish = LatLng(_locationDish[_current].latitude, _locationDish[_current].longitude);
moveCameraTo(locationDish);
},
);
setState(() {
_sliderDish = carouselSlider;
});
return carouselSlider;
}
}
Firestore function:
_getInfoDish() async{
List<LocationDish> _locationDishTmp = <LocationDish>[];
List<Dish> _dishCardTmp = <Dish>[];
bool hasFoodInArray = false;
Firestore.instance // Get the firebase instance
.collection(Constants.NAME_COLECTION) // Get the informations collection
.snapshots() // Get the Stream of DocumentSnapshot
.listen((QuerySnapshot snapshot){
_locationDishTmp.clear();
_dishCardTmp.clear();
print(":::::: - FIRESTORE - ::::::");
snapshot.documents.forEach((obj){
//Set dish to Cards
_dishCardTmp.add(
Dish(
id: obj.data["id"],
name: obj.data["name"],
photoURL: 'https://recetaparahoy.com/wp-content/uploads/2017/06/ceviche-peruano-630x420.jpg',
score: obj.data["score"].toDouble(),
),
);
});
if(_locationDishTmp.length > 0)
{
setState(() {
//add only food recent data
for(int i = 0; i < _locationDishTmp.length; i++){
_locationDish.add(_locationDishTmp[i]);
_dishCard.add(_dishCardTmp[i]);
}
//_current = _locationDish.length-1;
_hasFoodOnMap = true;
});
}
});
}
Please, someone could say me the error, or maybe any other solution to do that, I hope my explanation is clear, thx a lot!!!

