forked from eatvio/eatvio_app
fix-errors
This commit is contained in:
@@ -116,6 +116,9 @@ class _PhotoGalleryWidgetState extends State<PhotoGalleryWidget> {
|
||||
builder: (context, state) {
|
||||
if (state is DiaryStateLoaded) {
|
||||
int mealIndex = state.selectedMeal - 1;
|
||||
if (mealIndex < 0 || mealIndex >= state.diary.meals.length) {
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
final photos = state.diary.meals[mealIndex].photos;
|
||||
// BUG-5 fix: сбросить индекс, если он вышел за пределы
|
||||
// (например, после переключения на meal с меньшим числом фото)
|
||||
|
||||
@@ -20,6 +20,9 @@ class _ProductsListWidgetState extends State<ProductsListWidget> {
|
||||
builder: (BuildContext context, DiaryState state) {
|
||||
if (state is DiaryStateLoaded) {
|
||||
int mealIndex = state.selectedMeal - 1;
|
||||
if (mealIndex < 0 || mealIndex >= state.diary.meals.length) {
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
final portions = state.diary.meals[mealIndex].portions;
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
@@ -35,6 +38,9 @@ class _ProductsListWidgetState extends State<ProductsListWidget> {
|
||||
}
|
||||
if (state is DiaryStateLoadedTomorrowWithDiet) {
|
||||
int mealIndex = state.selectedMeal - 1;
|
||||
if (mealIndex < 0 || mealIndex >= state.diary.meals.length) {
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
final portions = state.diary.meals[mealIndex].portions;
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
|
||||
@@ -87,6 +87,11 @@ class _TimeOfMealPickerWidgetState extends State<TimeOfMealPickerWidget> {
|
||||
return BlocBuilder<DiaryCubit, DiaryState>(
|
||||
builder: (context, state) {
|
||||
if (state is DiaryStateLoaded) {
|
||||
final meals = state.diary.meals;
|
||||
final mealIndex = state.selectedMeal - 1;
|
||||
if (mealIndex < 0 || mealIndex >= meals.length) {
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
return Column(
|
||||
children: [
|
||||
const CustomDivider(),
|
||||
|
||||
Reference in New Issue
Block a user