fixed several runtime errors from client error reports
This commit is contained in:
@@ -42,7 +42,7 @@ Future<AvatarSheetResult?> showAvatarActionsSheet(
|
||||
onTap: () async {
|
||||
final bytes = await _pickAndCrop(
|
||||
sheetContext,
|
||||
() => FilePick.singleGalleryPick(sheetContext),
|
||||
() => FilePick.singleGalleryPick(sheetContext, forCrop: true),
|
||||
);
|
||||
if (bytes == null || !sheetContext.mounted) return;
|
||||
result = AvatarUploadResult(bytes);
|
||||
@@ -55,7 +55,7 @@ Future<AvatarSheetResult?> showAvatarActionsSheet(
|
||||
onTap: () async {
|
||||
final bytes = await _pickAndCrop(
|
||||
sheetContext,
|
||||
() => FilePick.cameraPick(sheetContext),
|
||||
() => FilePick.cameraPick(sheetContext, forCrop: true),
|
||||
);
|
||||
if (bytes == null || !sheetContext.mounted) return;
|
||||
result = AvatarUploadResult(bytes);
|
||||
|
||||
@@ -22,7 +22,7 @@ Future<Uint8List?> showChatBackgroundPickerSheet(BuildContext context) async {
|
||||
title: const Text('Aus Galerie wählen'),
|
||||
onTap: () async {
|
||||
final bytes = await _pickRaw(
|
||||
() => FilePick.singleGalleryPick(sheetContext),
|
||||
() => FilePick.singleGalleryPick(sheetContext, forCrop: true),
|
||||
);
|
||||
if (bytes == null || !sheetContext.mounted) return;
|
||||
result = bytes;
|
||||
@@ -33,7 +33,9 @@ Future<Uint8List?> showChatBackgroundPickerSheet(BuildContext context) async {
|
||||
leading: const Icon(Icons.photo_camera_outlined),
|
||||
title: const Text('Foto aufnehmen'),
|
||||
onTap: () async {
|
||||
final bytes = await _pickRaw(() => FilePick.cameraPick(sheetContext));
|
||||
final bytes = await _pickRaw(
|
||||
() => FilePick.cameraPick(sheetContext, forCrop: true),
|
||||
);
|
||||
if (bytes == null || !sheetContext.mounted) return;
|
||||
result = bytes;
|
||||
Navigator.of(sheetContext).pop();
|
||||
|
||||
@@ -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