@@ -95,83 +95,80 @@ class SendMessageWidgetState extends State<SendMessageWidget> {
9595 chatListConfig.scrollToBottomButtonConfig;
9696 return Align (
9797 alignment: Alignment .bottomCenter,
98- child: isCustomTextField
99- ? Builder (
100- // Assign the key only when using a custom text field to measure its height,
101- // to preventing overlap with the message list.
102- key: chatViewIW? .chatTextFieldViewKey,
103- builder: (context) {
104- WidgetsBinding .instance.addPostFrameCallback (
105- (_) => context.calculateAndUpdateTextFieldHeight (),
106- );
107- return widget.sendMessageBuilder? .call (_replyMessage) ??
108- const SizedBox .shrink ();
109- },
110- )
111- : SizedBox (
112- width: MediaQuery .of (context).size.width,
113- child: Stack (
98+ child: SizedBox (
99+ width: MediaQuery .of (context).size.width,
100+ child: Stack (
101+ children: [
102+ // This has been added to prevent messages from being
103+ // displayed below the text field
104+ // when the user scrolls the message list.
105+ Positioned (
106+ right: 0 ,
107+ left: 0 ,
108+ bottom: 0 ,
109+ child: Container (
110+ height: MediaQuery .of (context).size.height /
111+ ((! kIsWeb && Platform .isIOS) ? 24 : 28 ),
112+ color: chatListConfig.chatBackgroundConfig.backgroundColor ??
113+ Colors .white,
114+ ),
115+ ),
116+ Positioned (
117+ right: 0 ,
118+ left: 0 ,
119+ bottom: 0 ,
120+ child: Column (
121+ mainAxisSize: MainAxisSize .min,
114122 children: [
115- // This has been added to prevent messages from being
116- // displayed below the text field
117- // when the user scrolls the message list.
118- Positioned (
119- right: 0 ,
120- left: 0 ,
121- bottom: 0 ,
122- child: Container (
123- height: MediaQuery .of (context).size.height /
124- ((! kIsWeb && Platform .isIOS) ? 24 : 28 ),
125- color:
126- chatListConfig.chatBackgroundConfig.backgroundColor ??
127- Colors .white,
123+ if (chatViewIW
124+ ? .featureActiveConfig.enableScrollToBottomButton ??
125+ true )
126+ Align (
127+ alignment:
128+ scrollToBottomButtonConfig? .alignment? .alignment ??
129+ Alignment .bottomCenter,
130+ child: Padding (
131+ padding: scrollToBottomButtonConfig? .padding ??
132+ EdgeInsets .zero,
133+ child: const ScrollToBottomButton (),
134+ ),
128135 ),
129- ),
130- Positioned (
131- right: 0 ,
132- left: 0 ,
133- bottom: 0 ,
134- child: Column (
135- mainAxisSize: MainAxisSize .min,
136+ Padding (
137+ key: chatViewIW? .chatTextFieldViewKey,
138+ padding: EdgeInsets .fromLTRB (
139+ bottomPadding4,
140+ bottomPadding4,
141+ bottomPadding4,
142+ _bottomPadding,
143+ ),
144+ child: Stack (
145+ alignment: Alignment .bottomCenter,
136146 children: [
137- if (chatViewIW? .featureActiveConfig
138- .enableScrollToBottomButton ??
139- true )
140- Align (
141- alignment: scrollToBottomButtonConfig
142- ? .alignment? .alignment ??
143- Alignment .bottomCenter,
144- child: Padding (
145- padding: scrollToBottomButtonConfig? .padding ??
146- EdgeInsets .zero,
147- child: const ScrollToBottomButton (),
148- ),
149- ),
150- Padding (
151- key: chatViewIW? .chatTextFieldViewKey,
152- padding: EdgeInsets .fromLTRB (
153- bottomPadding4,
154- bottomPadding4,
155- bottomPadding4,
156- _bottomPadding,
147+ ReplyMessageView (
148+ key: _replyMessageTextFieldViewKey,
149+ sendMessageConfig: widget.sendMessageConfig,
150+ messageConfig: widget.messageConfig,
151+ builder: widget.replyMessageBuilder,
152+ onChange: (value) => _replyMessage = value,
153+ ),
154+ if (widget.sendMessageConfig.shouldSendImageWithText)
155+ SelectedImageViewWidget (
156+ key: _selectedImageViewWidgetKey,
157+ sendMessageConfig: widget.sendMessageConfig,
157158 ),
158- child: Stack (
159- alignment: Alignment .bottomCenter,
160- children: [
161- ReplyMessageView (
162- key: _replyMessageTextFieldViewKey,
163- sendMessageConfig: widget.sendMessageConfig,
164- messageConfig: widget.messageConfig,
165- builder: widget.replyMessageBuilder,
166- onChange: (value) => _replyMessage = value,
167- ),
168- if (widget
169- .sendMessageConfig.shouldSendImageWithText)
170- SelectedImageViewWidget (
171- key: _selectedImageViewWidgetKey,
172- sendMessageConfig: widget.sendMessageConfig,
173- ),
174- ChatUITextField (
159+ isCustomTextField
160+ ? Builder (
161+ builder: (context) {
162+ WidgetsBinding .instance.addPostFrameCallback (
163+ (_) => context
164+ .calculateAndUpdateTextFieldHeight (),
165+ );
166+ return widget.sendMessageBuilder
167+ ? .call (_replyMessage) ??
168+ const SizedBox .shrink ();
169+ },
170+ )
171+ : ChatUITextField (
175172 focusNode: _focusNode,
176173 textEditingController: _textEditingController,
177174 onPressed: _onPressed,
@@ -196,15 +193,15 @@ class SendMessageWidgetState extends State<SendMessageWidget> {
196193 }
197194 },
198195 ),
199- ],
200- ),
201- ),
202196 ],
203197 ),
204198 ),
205199 ],
206200 ),
207201 ),
202+ ],
203+ ),
204+ ),
208205 );
209206 }
210207
@@ -272,6 +269,10 @@ class SendMessageWidgetState extends State<SendMessageWidget> {
272269 _replyMessageTextFieldViewKey.currentState! .replyMessage.value =
273270 _replyMessage;
274271 }
272+ // Scroll to ensure the reply widget is visible and messages are not overlapped
273+ WidgetsBinding .instance.addPostFrameCallback ((_) {
274+ chatViewIW? .chatController.scrollToLastMessage ();
275+ });
275276 }
276277
277278 void onCloseTap () {
0 commit comments