From eaa2f73bcc3ad013601f4f98513a5044edf97956 Mon Sep 17 00:00:00 2001 From: "h.carnot" Date: Thu, 21 Apr 2022 15:45:38 +0200 Subject: [PATCH] feat: make image size editable --- lib/src/utils/matrix_file.dart | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/lib/src/utils/matrix_file.dart b/lib/src/utils/matrix_file.dart index 09f4af27..c111218a 100644 --- a/lib/src/utils/matrix_file.dart +++ b/lib/src/utils/matrix_file.dart @@ -70,10 +70,12 @@ class MatrixImageFile extends MatrixFile { required Uint8List bytes, required String name, String? mimeType, - this.width, - this.height, + int? width, + int? height, this.blurhash, - }) : super(bytes: bytes, name: name, mimeType: mimeType); + }) : _width = width, + _height = height, + super(bytes: bytes, name: name, mimeType: mimeType); /// Creates a new image file and calculates the width, height and blurhash. static Future create( @@ -137,11 +139,21 @@ class MatrixImageFile extends MatrixFile { return thumbnailFile; } + int? _width; + /// returns the width of the image - final int? width; + int? get width => _width; + + int? _height; /// returns the height of the image - final int? height; + int? get height => _height; + + /// If the image size is null, allow us to update it's value. + void setImageSizeIfNull({required int width, required int height}) { + _width ??= width; + _height ??= height; + } /// generates the blur hash for the image final String? blurhash;