Skip to content
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

Lack of information on how use attachmentBuilders with custom attachment types #1807

Open
1 task done
Mounix99 opened this issue Dec 6, 2023 · 8 comments
Open
1 task done
Labels
bug Something isn't working

Comments

@Mounix99
Copy link
Contributor

Mounix99 commented Dec 6, 2023

Which packages are you using?

stream_chat_flutter, stream_chat_persistance, stream_chat_localizations

On what platforms did you experience the issue?

iOS, Android, Web

What version are you using?

7.0.0

What happened?

customAttachmentBuilders was commented in the code and attachmentBuilders is unclear for custom attachment types.
THe only info about it's usage I can find is this comment

/// final myBuilders = [
 ///  ...StreamAttachmentWidgetBuilder.defaultBuilders,
 ///  MyCustomAttachmentBuilder(),
 ///  MyOtherCustomAttachmentBuilder(),
 ///  ...
 /// ];

But StreamAttachmentWidgetBuilder.defaultBuilders couldn't be imported, so how should I deal with my custom attachments, can you provide a valid example ?

previously I was using it like this:

defaultMessage.copyWith(customAttachmentBuilders: {
      AttachmentTypes.voicenote.name: (_, __, attachments) => AudioMessage(attachments: attachments),
      AttachmentTypes.currentLocation.name: (_, message, attachments) =>
          LocationMessage(attachments: attachments, channelName: channelName ?? message.text ?? ''),
    });

Steps to reproduce

Try to add custom attachments builders to StreamMessageWidget

Supporting info to reproduce

No response

Relevant log output

No response

Flutter analyze output

No response

Flutter doctor output

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@Mounix99 Mounix99 added the bug Something isn't working label Dec 6, 2023
@Mounix99
Copy link
Contributor Author

Any updates here ?

@Mounix99
Copy link
Contributor Author

Mounix99 commented Dec 14, 2023

Few points I mentioned while trying to deal with this new implementation

  1. StreamAttachmentWidgetBuilder.defaultBuilders isn't accessible, why? How can I get the list of default builders ?According to the provided snippets it should be accessible.
  2. If I have custom types of attachments along with the provided by the package in same message I can't handle them both and I'm forced to override MixedAttachmentBuilder with my own implantation, same to the GalleryAttachmentBuilder.
  3. If I want to add my custom attachmentBuilders to already existing in the StreamMessageWidget I can't get existing from StreamMessageWidget instance provided by StreamMessageListView.messageBuilder as a list and expand it with mine, In case if I try call StreamAttachmentWidgetBuilder.defaultBuilders as I already said in point 1 it is not accessible. In case if I call type specific StreamAttachmentWidgetBuilders directly I will have no control over provided by package onAttachmentTap methods and I need to handle them by my own

@Mounix99
Copy link
Contributor Author

@esarbanis Sorry for bothering you, but it is a big problem for our production along with the fact that without migrating to the stream_chat v7.x.x we blocked from updating the packages and migrating to last Flutter/Dart version. Can Some one at least mark it as an actual issue or provide me with any kind of solution ?

@khubaib-zeepalm
Copy link

I am running into the same issue

@mkobuolys
Copy link

mkobuolys commented Dec 19, 2023

I think the logic was moved to the StreamAttachmentWidgetBuilder and there is a static method StreamAttachmentWidgetBuilder.defaultBuilders to return all the builders. HOWEVER, this class is not exposed (exported) and it's a private class in the package, thus you are pretty much lost when adding a custom attachment builder.

@Mounix99
Copy link
Contributor Author

Mounix99 commented Dec 20, 2023

@mkobuolys this class is already accessible but it has problem with StreamAttachmentWidgetBuilder.defaultBuilders which contains MixedAttachmentBuilder and GalleryAttachmentBuilder that this two builders are collections of widgets of attachments and they will ignore your custom attachment if you will have both custom and native in one message. Also problem that the last builder in that list is FallbackAttachmentBuilder() which will basically ignore your attachment builders if they are placed in the end. And few more that I have described higher

@talkbiz
Copy link

talkbiz commented Jan 31, 2024

I'm having similar issue.

@Mounix99
Copy link
Contributor Author

#1826

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants