fix: Set image width and height

Uses the thumbnail generation of Matrix SDK.
This commit is contained in:
Christian Pauly 2022-02-03 07:35:44 +01:00
commit c600c74e3e
7 changed files with 47 additions and 124 deletions

View file

@ -7,7 +7,6 @@ import 'package:future_loading_dialog/future_loading_dialog.dart';
import 'package:matrix/matrix.dart';
import 'package:vrouter/vrouter.dart';
import '../../utils/resize_image.dart';
import '../../widgets/matrix.dart';
import 'settings_emotes_view.dart';
@ -206,14 +205,19 @@ class EmotesSettingsController extends State<EmotesSettings> {
name: result.fileName!,
);
try {
file = await file.resizeImage(calcBlurhash: false);
file = (await file.generateThumbnail(
compute: Matrix.of(context).client.runInBackground,
))!;
} catch (_) {
// do nothing
}
final uploadResp = await showFutureLoadingDialog(
context: context,
future: () => Matrix.of(context).client.uploadContent(file.bytes,
filename: file.name, contentType: file.mimeType),
future: () => Matrix.of(context).client.uploadContent(
file.bytes,
filename: file.name,
contentType: file.mimeType,
),
);
if (uploadResp.error == null) {
setState(() {