flyerhq / flutter_chat_ui

Actively maintained, community-driven chat UI implementation with an optional Firebase BaaS.
https://flyer.chat
Apache License 2.0
1.61k stars 696 forks source link

Duplicate GlobalKey detected in widget tree. #543

Open DilshadTechify opened 9 months ago

DilshadTechify commented 9 months ago

General

What bug do you experience? 🐞

Duplicate GlobalKey detected in widget tree.

How can it be reproduced? 🤔

Step 1. Click in Textfield and type a random message contains bunch of emoji Step 2. Send the message Step 2. Hide the keyboard manually

What behavior is expected? 💡

Once we type message with emoji and send the message then Keyboard should be automatically hide. It is not hiding automatically and throwing Error


Extras

Screenshots or videos 📸

Screenshot 2023-12-27 at 6 40 18 PM

Code snippets 📝

 Chat(
        messages: _messages,
        onMessageTap: (context, p1) {},
        onPreviewDataFetched: (p0, p1) {},
        theme: DefaultChatTheme(
          inputBackgroundColor: Colors.grey.withOpacity(0.3),
          dateDividerMargin: const EdgeInsets.symmetric(vertical: 10),
          highlightMessageColor: AppColors.primaryButtonColor,
          primaryColor: AppColors.primaryButtonColor,
          inputBorderRadius: BorderRadius.circular(8),
          inputTextCursorColor: AppColors.primaryAppBarColor,
          inputTextColor: AppColors.text.boldText,
          attachmentButtonMargin: EdgeInsets.zero,
          messageBorderRadius: 14,
          inputMargin: const EdgeInsets.all(2),
          inputPadding: const EdgeInsets.all(12),
          sentMessageBodyTextStyle: AppTextStyle.body.medium2.boldText,
          sentMessageBodyCodeTextStyle: AppTextStyle.body.medium2.boldText,
          sentMessageBodyLinkTextStyle: AppTextStyle.body.medium2.boldText.underLine.link,
          sentMessageCaptionTextStyle: AppTextStyle.title.small2.mareowBlue,
          sentMessageBodyBoldTextStyle: AppTextStyle.title.medium2.boldText,
          receivedMessageBodyTextStyle: AppTextStyle.body.medium2.boldText,
          receivedMessageBodyCodeTextStyle: AppTextStyle.body.medium2.boldText,
          receivedMessageBodyLinkTextStyle: AppTextStyle.body.medium2.boldText.underLine.link,
          receivedMessageCaptionTextStyle: AppTextStyle.title.small2.mareowBlue,
          receivedMessageBodyBoldTextStyle: AppTextStyle.title.medium2.boldText,
          messageInsetsVertical: 10,
          errorIcon: const Icon(Icons.error, color: Colors.red),
          errorColor: Colors.red,
          attachmentButtonIcon: const Icon(
            Icons.attach_file_rounded,
            color: AppColors.primaryAppBarColor,
          ),
        ),
        hideBackgroundOnEmojiMessages: true,
        inputOptions: InputOptions(
            inputClearMode: InputClearMode.always,
            enableSuggestions: true,
            textEditingController: _messageController,
            sendButtonVisibilityMode: SendButtonVisibilityMode.always),
        emojiEnlargementBehavior: EmojiEnlargementBehavior.multi,
        onSendPressed: (p0) {
          _handleSendPressed(p0);
          setState(() {});
        },
        showUserAvatars: true,
        showUserNames: true,
        usePreviewData: true,
        bubbleRtlAlignment: BubbleRtlAlignment.left,
        onAttachmentPressed: () async {
          _handleFileSelection();
          setState(() {});
        },
        imageGalleryOptions: const ImageGalleryOptions(),
        user: _user,
      ),


Environment info

Please specify the flutter, flutter-chat-ui versions.

flutter: 3.16.5- stable

flutter-chat-ui: ^1.6.10

flutter doctor -v output 👇

Screenshot 2023-12-27 at 6 42 00 PM


Platform

Device: iOS , Android

OS version):


Additional context

Add any other context about the problem here.

demchenkoalex commented 9 months ago

so like this? looks fine to me. Are you sure your messages have unique ID?

https://github.com/flyerhq/flutter_chat_ui/assets/14123304/ca190a84-30d0-4485-8664-34b0655d5d20

fabioselau077 commented 8 months ago

so like this? looks fine to me. Are you sure your messages have unique ID?

Screen.Recording.2023-12-27.at.22.23.37.mov

same here... problem is when using pagination

https://github.com/flyerhq/flutter_chat_ui/assets/57275833/c4245c1f-1c58-40dd-b0e2-41e45bd20e68

@edit: I believe the problem is with duplicate ids in messages

demchenkoalex commented 7 months ago

yeah, in v2 I will make asserts that will be throwing an error if this happens. Unique IDs are very important to differentiate messages.