diff --git a/lib/utils/matrix_sdk_extensions.dart/event_extension.dart b/lib/utils/matrix_sdk_extensions.dart/event_extension.dart index b1d3231d..c9d98070 100644 --- a/lib/utils/matrix_sdk_extensions.dart/event_extension.dart +++ b/lib/utils/matrix_sdk_extensions.dart/event_extension.dart @@ -5,6 +5,7 @@ import 'package:flutter_cache_manager/flutter_cache_manager.dart'; import 'package:future_loading_dialog/future_loading_dialog.dart'; import 'package:matrix/matrix.dart'; +import 'package:fluffychat/utils/size_string.dart'; import 'matrix_file_extension.dart'; extension LocalizedBody on Event { @@ -42,15 +43,10 @@ extension LocalizedBody on Event { isThumbnailSmallEnough || (content['url'] is String)); - String? get sizeString { - if (content['info'] is Map && - content['info'].containsKey('size')) { - final size = content['info']['size']; - return size.sizeString; - } else { - return null; - } - } + String? get sizeString => content + .tryGetMap('info') + ?.tryGet('size') + ?.sizeString; static final _downloadAndDecryptFutures = >{};