forked from eatvio/eatvio_app
feat(diary): Saving filtering value to the state
This commit is contained in:
@@ -432,6 +432,7 @@ class DiaryEditBloc extends Bloc<DiaryEditEvent, DiaryEditState> {
|
||||
ProductInput event, Emitter<DiaryEditState> emit) async {
|
||||
if (state is DiaryEditLoadedState) {
|
||||
var currentState = state as DiaryEditLoadedState;
|
||||
print(currentState.productNameController!.text);
|
||||
String? token = currentState.token;
|
||||
final credentials = {
|
||||
'name': event.input,
|
||||
@@ -445,16 +446,18 @@ class DiaryEditBloc extends Bloc<DiaryEditEvent, DiaryEditState> {
|
||||
'Authorization': 'Bearer $token',
|
||||
},
|
||||
);
|
||||
print(response.body);
|
||||
final productNutritionalValues =
|
||||
jsonDecode(response.body)['productNutritionalValue'];
|
||||
if (productNutritionalValues is Map<String, dynamic>) {
|
||||
jsonDecode(response.body)['product_nutritional_value'];
|
||||
if (productNutritionalValues is List<dynamic>) {
|
||||
var updatedState = currentState.copyWith(
|
||||
autocompleteList: productNutritionalValues.values
|
||||
.map((value) => value['name'])
|
||||
autocompleteList: productNutritionalValues
|
||||
.map((product) => product['name'])
|
||||
.toList());
|
||||
|
||||
print(updatedState.autocompleteList);
|
||||
emit(updatedState);
|
||||
} else {
|
||||
print("Ошибка в декодировании ответа из API");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user