fixed several runtime errors from client error reports
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user