forked from eatvio/eatvio_app
feat(diary) Portion data send displayy fix
This commit is contained in:
@@ -346,14 +346,15 @@ class DiaryEditBloc extends Bloc<DiaryEditEvent, DiaryEditState> {
|
||||
if (state is DiaryEditLoadedState) {
|
||||
var currentState = state as DiaryEditLoadedState;
|
||||
int? id = event.value.id;
|
||||
emit(currentState.copyWith(
|
||||
DiaryEditLoadedState updatedState = currentState.copyWith(
|
||||
currentMeal: event.value,
|
||||
portions: event.meals?[event.value.id ?? 0]['portions'],
|
||||
mealTimeController:
|
||||
toTime(event.meals?[event.value.id ?? 0]['time'] ?? "1$id:00"),
|
||||
selectedMood: event.meals?[event.value.id ?? 0]['mood'],
|
||||
selectedSatiety: event.meals?[event.value.id ?? 0]['satiety']));
|
||||
currentState.currentMeal = event.value;
|
||||
selectedSatiety: event.meals?[event.value.id ?? 0]['satiety']);
|
||||
emit(updatedState);
|
||||
print(updatedState.portions);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -393,12 +394,19 @@ class DiaryEditBloc extends Bloc<DiaryEditEvent, DiaryEditState> {
|
||||
currentState.currentMeal!.id,
|
||||
currentState.diaryId);
|
||||
if (response.statusCode == 200) {
|
||||
dynamic responseData = jsonDecode(response.body);
|
||||
var newPortion = responseData['portion']
|
||||
as int; // Assuming the portion quantity is an integer
|
||||
|
||||
// Ensure meals and id are correctly accessed and handle null values
|
||||
var currentPortions =
|
||||
currentState.meals?[id ?? 0]['portions'] as int ?? 0;
|
||||
|
||||
var updatedState = currentState.copyWith(
|
||||
portions: currentState.meals?[id ?? 0]['portions'],
|
||||
portions: currentPortions + newPortion,
|
||||
);
|
||||
print(currentState.portions);
|
||||
print(updatedState.portions);
|
||||
emit(updatedState); // Передаем обновленное состояние в emit
|
||||
|
||||
emit(updatedState);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -217,7 +217,7 @@ class DiaryEditScreen extends StatelessWidget {
|
||||
final digitsOnly = FilteringTextInputFormatter.digitsOnly;
|
||||
List<String> _options =
|
||||
state.autocompleteList!.map((dynamic item) => item as String).toList();
|
||||
print(_options);
|
||||
//print(_options);
|
||||
return Container(
|
||||
margin: EdgeInsets.symmetric(horizontal: 16.h),
|
||||
padding: EdgeInsets.symmetric(
|
||||
|
||||
Reference in New Issue
Block a user