fix: resize images in a separate isolate

This commit is contained in:
Sorunome 2020-10-06 18:22:50 +02:00
commit a113f99135
6 changed files with 131 additions and 113 deletions

View file

@ -227,31 +227,16 @@ class _ChatState extends State<_Chat> {
}
void sendImageAction(BuildContext context) async {
MatrixImageFile file;
if (PlatformInfos.isMobile) {
final result = await ImagePicker().getImage(
source: ImageSource.gallery,
imageQuality: 50,
maxWidth: 1600,
maxHeight: 1600);
if (result == null) return;
file = MatrixImageFile(
bytes: await result.readAsBytes(),
name: result.path,
);
} else {
final result =
await FilePickerCross.importFromStorage(type: FileTypeCross.image);
if (result == null) return;
file = MatrixImageFile(
bytes: result.toUint8List(),
name: result.fileName,
);
}
final result =
await FilePickerCross.importFromStorage(type: FileTypeCross.image);
if (result == null) return;
await showDialog(
context: context,
builder: (context) => SendFileDialog(
file: file,
file: MatrixImageFile(
bytes: result.toUint8List(),
name: result.fileName,
),
room: room,
),
);