forked from eatvio/eatvio_app
updated error handling, consultant rating layout and complaining logic
This commit is contained in:
@@ -323,7 +323,7 @@ class CreateDietCubit extends Cubit<CreateDietState> {
|
||||
|
||||
Future<String?> createDiet() async {
|
||||
emit(state.copyWith(isDietPublishing: true));
|
||||
if (!_isFromValid()) return null;
|
||||
if (!_isFromValid()) return 'validation';
|
||||
try {
|
||||
final image = await ImageCompressUtility.compressFile(File(state.dietData.image!.path));
|
||||
final dietState = state.dietData.state!;
|
||||
@@ -342,16 +342,16 @@ class CreateDietCubit extends Cubit<CreateDietState> {
|
||||
);
|
||||
|
||||
emit(state.copyWith(published: dietState != DietState.draft, drafted: dietState == DietState.draft));
|
||||
return state.dietData.name;
|
||||
return null;
|
||||
} on DioException catch (e, stackTrace) {
|
||||
log(e.toString(), stackTrace: stackTrace);
|
||||
}
|
||||
emit(state.copyWith(isDietPublishing: false));
|
||||
return null;
|
||||
return 'error';
|
||||
}
|
||||
|
||||
Future<String?> updateDiet(int dietId) async {
|
||||
if (!_isFromValid()) return null;
|
||||
if (!_isFromValid()) return 'error';
|
||||
try {
|
||||
File? image;
|
||||
if (state.dietData.image != null) {
|
||||
@@ -373,7 +373,7 @@ class CreateDietCubit extends Cubit<CreateDietState> {
|
||||
return null;
|
||||
} catch (e, st) {
|
||||
log(e.toString(), stackTrace: st);
|
||||
return 'Произошла непредвиденная ошибка';
|
||||
return 'error';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user