From 2135fdb971acd69fea05460b15526096027d9117 Mon Sep 17 00:00:00 2001 From: Deven Joshi Date: Fri, 2 Apr 2021 15:36:40 +0530 Subject: [PATCH] fix: attachments upload when size exceeds (#377) * fix: Fixed file upload error * fix: Fixed file upload error --- packages/stream_chat_flutter/lib/src/message_input.dart | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/stream_chat_flutter/lib/src/message_input.dart b/packages/stream_chat_flutter/lib/src/message_input.dart index f22e127c..13da9b70 100644 --- a/packages/stream_chat_flutter/lib/src/message_input.dart +++ b/packages/stream_chat_flutter/lib/src/message_input.dart @@ -1125,6 +1125,7 @@ class MessageInputState extends State { _showErrorAlert( 'The file is too large to upload. The file size limit is 20MB.', ); + return; } } @@ -1988,8 +1989,6 @@ class MessageInputState extends State { extraData: extraDataMap.isNotEmpty ? extraDataMap : null, ); - _attachments[attachment.id] = attachment; - if (file.size > _kMaxAttachmentSize) { if (attachmentType == 'Video') { final mediaInfo = await VideoService.compressVideo(file.path); @@ -1998,7 +1997,6 @@ class MessageInputState extends State { _showErrorAlert( 'The file is too large to upload. The file size limit is 20MB. We tried compressing it, but it was not enough.', ); - _attachments.remove(attachment.id); return; } file = AttachmentFile( @@ -2011,9 +2009,12 @@ class MessageInputState extends State { _showErrorAlert( 'The file is too large to upload. The file size limit is 20MB.', ); + return; } } + _attachments[attachment.id] = attachment; + setState(() { _attachments.update(attachment.id, (it) { return it.copyWith(