review: fixed review issues

This commit is contained in:
misha
2026-02-20 13:20:17 +03:00
parent 699148b202
commit 67e770f5d0
8 changed files with 131 additions and 5 deletions

View File

@@ -199,11 +199,17 @@ class CreateDietCubit extends Cubit<CreateDietState> {
}
}
static const int _maxImageBytesForBase64 = 5 * 1024 * 1024;
Future<Diet?> getDietForPreview() async {
if (!_isFormValidForDraft()) return null;
final authorProfile = await profileRepository.getMyProfile();
final imageBytes = (await state.dietData.image?.readAsBytes()) ?? <int>[];
String image = base64.encode(imageBytes);
String image = '';
if (imageBytes.isNotEmpty && imageBytes.length <= _maxImageBytesForBase64) {
image = base64.encode(imageBytes);
}
if (image.isEmpty && state.dietData.imageUrl != null) {
image = state.dietData.imageUrl ?? '';
}