fixed several runtime errors from client error reports

This commit is contained in:
2026-09-26 00:06:18 +02:00
parent 56a497985b
commit d6130584f2
6 changed files with 39 additions and 10 deletions
+24 -4
View File
@@ -23,11 +23,31 @@ class FilePick {
return pickedImages.isNotEmpty ? pickedImages : null;
});
static Future<XFile?> singleGalleryPick(BuildContext context) =>
_guarded(context, () => _picker.pickImage(source: ImageSource.gallery));
static Future<XFile?> singleGalleryPick(
BuildContext context, {
bool forCrop = false,
}) => _pickImage(context, ImageSource.gallery, forCrop: forCrop);
static Future<XFile?> cameraPick(BuildContext context) =>
_guarded(context, () => _picker.pickImage(source: ImageSource.camera));
static Future<XFile?> cameraPick(
BuildContext context, {
bool forCrop = false,
}) => _pickImage(context, ImageSource.camera, forCrop: forCrop);
/// [forCrop] makes the picker re-encode to a bounded JPEG: the Dart cropper
/// can't decode HEIC (iOS gallery default) and is slow on full-size photos.
static Future<XFile?> _pickImage(
BuildContext context,
ImageSource source, {
required bool forCrop,
}) => _guarded(
context,
() => _picker.pickImage(
source: source,
maxWidth: forCrop ? 2048 : null,
maxHeight: forCrop ? 2048 : null,
imageQuality: forCrop ? 90 : null,
),
);
static Future<List<String>?> documentPick() async {
final result = await FilePicker.pickFiles(allowMultiple: true);