forked from eatvio/eatvio_app
feat(diary): Refresh page after product remove
This commit is contained in:
@@ -480,21 +480,11 @@ class DiaryEditBloc extends Bloc<DiaryEditEvent, DiaryEditState> {
|
||||
currentState.diaryId,
|
||||
);
|
||||
|
||||
print(currentState.portions);
|
||||
print(response.body);
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
dynamic newPortion = jsonDecode(response.body)['portion'];
|
||||
|
||||
final updatedPortions = List.from(currentState.portions ?? [])
|
||||
..add(newPortion);
|
||||
|
||||
final updatedState = currentState.copyWith(portions: updatedPortions);
|
||||
|
||||
print(updatedState.portions);
|
||||
|
||||
emit(updatedState); // Emit the updated state
|
||||
await reloadScreen(event, emit);
|
||||
} else {
|
||||
// Handling error when response status code is not 200
|
||||
print(
|
||||
'Failed to add portion. Status Code: ${response.statusCode} ${response.body}');
|
||||
}
|
||||
@@ -582,7 +572,10 @@ class DiaryEditBloc extends Bloc<DiaryEditEvent, DiaryEditState> {
|
||||
);
|
||||
|
||||
if (response.statusCode == 204) {
|
||||
reloadScreen(event, emit);
|
||||
await reloadScreen(event, emit);
|
||||
} else {
|
||||
print(
|
||||
'Failed to add portion. Status Code: ${response.statusCode} ${response.body}');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user