GetStream / stream-chat-flutter

Flutter Chat SDK - Build your own chat app experience using Dart, Flutter and the Stream Chat Messaging API.
https://getstream.io/chat/sdk/flutter/
Other
880 stars 313 forks source link

Default attachment preview is not working, after adding custom attachment builder #1961

Closed TMuthu closed 1 week ago

TMuthu commented 1 week ago

Which packages are you using?

stream_chat_flutter

On what platforms did you experience the issue?

iOS, Android

What version are you using?

7.2.2

What happened?

StreamMessageListView(
       initialScrollIndex: widget.initialScrollIndex,
       initialAlignment: widget.initialAlignment,
       highlightInitialMessage: widget.highlightInitialMessage,
       markReadWhenAtTheBottom: true,
       messageFilter: defaultFilter,
       messageBuilder:
       (context, details, messages, defaultMessage) {
               final channel = StreamChannel.of(context).channel;
               final userId = StreamChat.of(context).currentUser!.id;
               final isMyMessage =  defaultMessage.message.user?.id == userId;
               return defaultMessage.copyWith(
                        customActions: [
                          if (isMyMessage)
                            StreamMessageAction(
                              leading: const Icon(Icons.remove_red_eye),
                              title: const Text('Info'),
                              onTap: (message) {
                                Navigator.push(
                                    context,
                                    PageTransition(
                                        type: PageTransitionType.rightToLeft,
                                        child: ReadUnreadUsersWidget(
                                            message: message, channel: channel),
                                        duration:
                                            const Duration(milliseconds: 300)));
                              },
                            ),
                        ],
                        onReplyTap: _reply,
                        onShowMessage: (m, c) async {
                          final client = StreamChat.of(context).client;
                          final message = m;
                          final channel = client.channel(
                            c.type,
                            id: c.id,
                          );
                          if (channel.state == null) {
                            await channel.watch();
                          }
                          if (!mounted) return;
                          navigateToChannelPage(
                              context, channel, message, false);
                        },
                        bottomRowBuilderWithDefaultWidget: (
                          context,
                          message,
                          defaultWidget,
                        ) {
                          return defaultWidget.copyWith(
                            deletedBottomRowBuilder: (context, message) {
                              return const StreamVisibleFootnote();
                            },
                          );
                        },
                        attachmentBuilders: [
                          ...StreamAttachmentWidgetBuilder.defaultBuilders(
                            message: details.message,
                          ),
                          AudioAttachmentBuilder(),
                          LocationAttachmentBuilder(channel: channel),
                        ],
                      );
                    },
                    threadBuilder: (_, parentMessage) {
                      return ThreadPage(parent: parentMessage!);
                    },
  )

I have added custom builder to dispaly location and audio attachments using attachmentBuilders prop. After this change default attachment builders onAttachmentTab function is stopped working. How to add custom attachment builders without affecting default builder?

Steps to reproduce

Attach Custom attachment builders using attachmentBuilders property. 
Upload Image or Video
Try to open attachment

Supporting info to reproduce

No response

Relevant log output

No response

Flutter analyze output

No response

Flutter doctor output

[√] Flutter (Channel stable, 3.16.8, on Microsoft Windows [Version 10.0.22621.3593], locale en-IN)
    • Flutter version 3.16.8 on channel stable at C:\src\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 67457e669f (5 months ago), 2024-01-16 16:22:29 -0800
    • Engine revision 6e2ea58a5c
    • Dart version 3.2.5
    • DevTools version 2.28.5

[√] Windows Version (Installed version of Windows is version 10 or higher)

[√] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at C:\Users\Admin\AppData\Local\Android\sdk
    • Platform android-34, build-tools 34.0.0
    • Java binary at: C:\Program Files\Android\Android Studio\jbr\bin\java
    • Java version OpenJDK Runtime Environment (build 17.0.7+0-b2043.56-10550314)
    • All Android licenses accepted.

[√] Chrome - develop for the web
    • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[!] Visual Studio - develop Windows apps (Visual Studio Build Tools 2019 16.11.20)
    • Visual Studio at C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools
    • Visual Studio Build Tools 2019 version 16.11.32929.386
    X The current Visual Studio installation is incomplete.
      Please use Visual Studio Installer to complete the installation or reinstall Visual Studio.

[√] Android Studio (version 2023.1)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.7+0-b2043.56-10550314)

[√] VS Code (version 1.90.2)
    • VS Code at C:\Users\Admin\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension can be installed from:
       https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

[√] Connected device (4 available)
    • sdk gphone64 x86 64 (mobile) • emulator-5554 • android-x64    • Android 14 (API 34) (emulator)
    • Windows (desktop)            • windows       • windows-x64    • Microsoft Windows [Version 10.0.22621.3593]
    • Chrome (web)                 • chrome        • web-javascript • Google Chrome 126.0.6478.63
    • Edge (web)                   • edge          • web-javascript • Microsoft Edge 125.0.2535.85

[√] Network resources
    • All expected network resources are available.

Code of Conduct

deven98 commented 1 week ago

Hey @TMuthu 👋

With 7.2.2 you do not need to add the default builders in the attachmentBuilders anymore. Can you simply remove the default builders in your code and let me know if it works?

Thanks.

TMuthu commented 1 week ago

Hi @deven98 , After removing the default builders, it is working fine. Thanks for your reply.