-
Notifications
You must be signed in to change notification settings - Fork 211
fix: 🐛 ensure images are properly added to preview when sending messages with text #430
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -1152,11 +1152,22 @@ PackageStrings.setLocale('es'); | |||||||||||||||||||||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| ## Send Image With Message | ||||||||||||||||||||||||||||||||||||||||||||||||
| You can send images along with your messages by enabling the `shouldSendImageWithText` flag in `sendMessageConfig` all the other things will be handled by the package itself. Here's how to do it: | ||||||||||||||||||||||||||||||||||||||||||||||||
| You can send images along with your messages by enabling the `shouldSendImageWithText` option in `sendMessageConfig` and use `ChatView.handleImageSelection` to display an image preview. Here's how to do it: | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| ```dart | ||||||||||||||||||||||||||||||||||||||||||||||||
| sendMessageConfig: SendMessageConfiguration( | ||||||||||||||||||||||||||||||||||||||||||||||||
| shouldSendImageWithText: true, // Enable sending images with text | ||||||||||||||||||||||||||||||||||||||||||||||||
| trailingActions: (context, controller) => [ | ||||||||||||||||||||||||||||||||||||||||||||||||
| GalleryActionButton( | ||||||||||||||||||||||||||||||||||||||||||||||||
| icon: Icon( | ||||||||||||||||||||||||||||||||||||||||||||||||
| Icons.photo_rounded, | ||||||||||||||||||||||||||||||||||||||||||||||||
| size: 30, | ||||||||||||||||||||||||||||||||||||||||||||||||
| color: _theme.iconColor, | ||||||||||||||||||||||||||||||||||||||||||||||||
| ), | ||||||||||||||||||||||||||||||||||||||||||||||||
| onPressed: (path, replyMessage) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| ChatView.handleImageSelection(context, path!); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
| ChatView.handleImageSelection(context, path!); | |
| if (path != null && path.isNotEmpty) { | |
| ChatView.handleImageSelection(context, path); | |
| } |
Copilot
AI
Jan 30, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The documentation example is using trailingActions directly on SendMessageConfiguration, but that property is on TextFieldConfiguration (sendMessageConfig.textFieldConfig.trailingActions). As written, the snippet won’t compile and may mislead users.
| trailingActions: (context, controller) => [ | |
| GalleryActionButton( | |
| icon: Icon( | |
| Icons.photo_rounded, | |
| size: 30, | |
| color: _theme.iconColor, | |
| ), | |
| onPressed: (path, replyMessage) { | |
| ChatView.handleImageSelection(context, path!); | |
| }, | |
| textFieldConfig: TextFieldConfiguration( | |
| trailingActions: (context, controller) => [ | |
| GalleryActionButton( | |
| icon: Icon( | |
| Icons.photo_rounded, | |
| size: 30, | |
| color: _theme.iconColor, | |
| ), | |
| onPressed: (path, replyMessage) { | |
| ChatView.handleImageSelection(context, path!); | |
| }, | |
| ), | |
| ], |
Copilot
AI
Jan 30, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The GalleryActionButton snippet in this code block has mismatched indentation/parentheses and is missing the closing ] / ) needed to end trailingActions and SendMessageConfiguration, so the example won’t compile as-is. Please fix the bracket/parenthesis structure so the snippet is valid Dart.
| icon: Icon( | |
| Icons.photo_rounded, | |
| size: 30, | |
| color: _theme.iconColor, | |
| ), | |
| onPressed: (path, replyMessage) { | |
| ChatView.handleImageSelection(context, path!); | |
| }, | |
| ), | |
| icon: Icon( | |
| Icons.photo_rounded, | |
| size: 30, | |
| color: _theme.iconColor, | |
| ), | |
| onPressed: (path, replyMessage) { | |
| ChatView.handleImageSelection(context, path!); | |
| }, | |
| ), | |
| ], |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -178,22 +178,7 @@ class SendMessageWidgetState extends State<SendMessageWidget> { | |||||||||||||||||||||||||||||||||||||||||||||
| sendMessageConfig: widget.sendMessageConfig, | ||||||||||||||||||||||||||||||||||||||||||||||
| onRecordingComplete: _onRecordingComplete, | ||||||||||||||||||||||||||||||||||||||||||||||
| onImageSelected: (images, messageId) { | ||||||||||||||||||||||||||||||||||||||||||||||
| if (widget.sendMessageConfig | ||||||||||||||||||||||||||||||||||||||||||||||
| .shouldSendImageWithText) { | ||||||||||||||||||||||||||||||||||||||||||||||
| if (images.isNotEmpty) { | ||||||||||||||||||||||||||||||||||||||||||||||
| _selectedImageViewWidgetKey.currentState | ||||||||||||||||||||||||||||||||||||||||||||||
| ?.selectedImages.value = [ | ||||||||||||||||||||||||||||||||||||||||||||||
| ...?_selectedImageViewWidgetKey | ||||||||||||||||||||||||||||||||||||||||||||||
| .currentState?.selectedImages.value, | ||||||||||||||||||||||||||||||||||||||||||||||
| images | ||||||||||||||||||||||||||||||||||||||||||||||
| ]; | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| FocusScope.of(context) | ||||||||||||||||||||||||||||||||||||||||||||||
| .requestFocus(_focusNode); | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| _onImageSelected(images, ''); | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
| handleImageSelection(images); | ||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
180
to
182
|
||||||||||||||||||||||||||||||||||||||||||||||
| ), | ||||||||||||||||||||||||||||||||||||||||||||||
| ], | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -284,6 +269,21 @@ class SendMessageWidgetState extends State<SendMessageWidget> { | |||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| /// Handles image selection and focus logic. Can be called externally to add images to the selection. | ||||||||||||||||||||||||||||||||||||||||||||||
| void handleImageSelection(String images) { | ||||||||||||||||||||||||||||||||||||||||||||||
| if (widget.sendMessageConfig.shouldSendImageWithText) { | ||||||||||||||||||||||||||||||||||||||||||||||
| if (images.isNotEmpty) { | ||||||||||||||||||||||||||||||||||||||||||||||
| _selectedImageViewWidgetKey.currentState?.selectedImages.value = [ | ||||||||||||||||||||||||||||||||||||||||||||||
| ...?_selectedImageViewWidgetKey.currentState?.selectedImages.value, | ||||||||||||||||||||||||||||||||||||||||||||||
| images | ||||||||||||||||||||||||||||||||||||||||||||||
| ]; | ||||||||||||||||||||||||||||||||||||||||||||||
| FocusScope.of(context).requestFocus(_focusNode); | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| _onImageSelected(images, ''); | ||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+273
to
+283
|
||||||||||||||||||||||||||||||||||||||||||||||
| void handleImageSelection(String images) { | |
| if (widget.sendMessageConfig.shouldSendImageWithText) { | |
| if (images.isNotEmpty) { | |
| _selectedImageViewWidgetKey.currentState?.selectedImages.value = [ | |
| ...?_selectedImageViewWidgetKey.currentState?.selectedImages.value, | |
| images | |
| ]; | |
| FocusScope.of(context).requestFocus(_focusNode); | |
| } | |
| } else { | |
| _onImageSelected(images, ''); | |
| void handleImageSelection(String imagePath) { | |
| if (widget.sendMessageConfig.shouldSendImageWithText) { | |
| if (imagePath.isNotEmpty) { | |
| _selectedImageViewWidgetKey.currentState?.selectedImages.value = [ | |
| ...?_selectedImageViewWidgetKey.currentState?.selectedImages.value, | |
| imagePath | |
| ]; | |
| FocusScope.of(context).requestFocus(_focusNode); | |
| } | |
| } else { | |
| _onImageSelected(imagePath, ''); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changelog entry wording is a bit unclear/grammatically awkward (“Added … to use … parameter …”). Consider rephrasing to something like: “Added
ChatView.handleImageSelectionto supportshouldSendImageWithTextwhen using customtrailingActions.”