Стоит отметить, что мое приложение работает так, как ожидалось, но, похоже, оно постоянно перестраивается, а не при внесении изменений. Если я удалю функцию getAllFavoriteRecipes, приложение не будет обновляться, если не будет перемещаться вперед и назад. т.е. обновление состояния.
body: StreamBuilder(
stream:
Firestore.instance.collection('users').document(uid).snapshots(),
builder: (context, snapshot) {
if (!snapshot.hasData) {
return Loading();
} else {
favoriteIDs = snapshot.data['favorites'];
getAllFavoriteRecipes(recipeNotifier, favoriteIDs);
Получить все любимые рецепты.
getAllFavoriteRecipes(RecipeNotifier recipeNotifier, favoriteIDs) async {
//print('Service FavoriteIDs: $favoriteIDs');
QuerySnapshot snapshot = await Firestore.instance
.collection('recipes')
.where('recipeID', whereIn: favoriteIDs)
.getDocuments();
List<RecipeList> _recipes = [];
snapshot.documents.forEach((document) {
RecipeList recipe = RecipeList.fromMap(document.data);
_recipes.add(recipe);
});
recipeNotifier.recipeList = _recipes;
}
Это журнал, показывающий, что приложение правильно перестраивается при добавлении / удалении элементов, но также перестраивается постоянно.
I/flutter (13220): Rebuilt
I/flutter (13220): [yGkfj33jruv7acpVkakVDecgW, dYWcxwn66N6Tpc4GBX5Y67SGS, WN73rDVgxS3HkKF8X2YJTuEwv]
I/flutter (13220): removed
I/flutter (13220): Rebuilt
I/flutter (13220): [yGkfj33jruv7acpVkakVDecgW, dYWcxwn66N6Tpc4GBX5Y67SGS, WN73rDVgxS3HkKF8X2YJTuEwv]
I/flutter (13220): Rebuilt
I/flutter (13220): [yGkfj33jruv7acpVkakVDecgW, WN73rDVgxS3HkKF8X2YJTuEwv]
I/flutter (13220): Rebuilt
I/flutter (13220): [yGkfj33jruv7acpVkakVDecgW, WN73rDVgxS3HkKF8X2YJTuEwv]
I/flutter (13220): Rebuilt