Skip to content

Commit cd7728c

Browse files
fix: 🐛 Dispose the animated list controller
1 parent 7b44ea6 commit cd7728c

File tree

4 files changed

+18
-14
lines changed

4 files changed

+18
-14
lines changed

example/lib/example_two/example_two_chat_screen.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import '../values/colors.dart';
99
import '../values/borders.dart';
1010
import '../values/icons.dart';
1111
import '../values/images.dart';
12+
import '../widgets/custom_chat_bar.dart';
1213
import '../widgets/reply_message_tile.dart';
13-
import '../widgets/wp_custom_chat_bar.dart';
1414

1515
class ExampleTwoChatScreen extends StatefulWidget {
1616
const ExampleTwoChatScreen({required this.chat, super.key});
@@ -175,7 +175,7 @@ class _ExampleTwoChatScreenState extends State<ExampleTwoChatScreen> {
175175
),
176176
chatBackgroundConfig: ChatBackgroundConfiguration(
177177
backgroundColor: AppColors.uiTwoBackground,
178-
backgroundImage: AppImages.wpChatBackground,
178+
backgroundImage: AppImages.uiTwoChatBackground,
179179
groupSeparatorBuilder: (separator) => _customSeparator(separator),
180180
),
181181
chatBubbleConfig: ChatBubbleConfiguration(
@@ -282,7 +282,7 @@ class _ExampleTwoChatScreenState extends State<ExampleTwoChatScreen> {
282282
onLeftSwipe: null,
283283
onRightSwipe: null,
284284
),
285-
sendMessageBuilder: (replyMessage) => WpCustomChatBar(
285+
sendMessageBuilder: (replyMessage) => CustomChatBar(
286286
chatController: _chatController,
287287
replyMessage: replyMessage ?? const ReplyMessage(),
288288
onAttachPressed: () => ScaffoldMessenger.of(context).showSnackBar(

example/lib/values/images.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
class AppImages {
2-
static const String wpChatBackground = "assets/images/chat_background.png";
2+
static const String uiTwoChatBackground = "assets/images/chat_background.png";
33
}

example/lib/widgets/wp_custom_chat_bar.dart renamed to example/lib/widgets/custom_chat_bar.dart

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import 'package:audio_waveforms/audio_waveforms.dart';
99
import '../../values/colors.dart';
1010
import '../../values/icons.dart';
1111

12-
class WpCustomChatBar extends StatefulWidget {
13-
const WpCustomChatBar({
12+
class CustomChatBar extends StatefulWidget {
13+
const CustomChatBar({
1414
required this.chatController,
1515
required this.replyMessage,
1616
this.onAttachPressed,
@@ -22,10 +22,10 @@ class WpCustomChatBar extends StatefulWidget {
2222
final VoidCallback? onAttachPressed;
2323

2424
@override
25-
State<WpCustomChatBar> createState() => _WpCustomChatBarState();
25+
State<CustomChatBar> createState() => _CustomChatBarState();
2626
}
2727

28-
class _WpCustomChatBarState extends State<WpCustomChatBar> {
28+
class _CustomChatBarState extends State<CustomChatBar> {
2929
RecorderController? controller;
3030
late ReplyMessage? _replyMessage = widget.replyMessage;
3131
final voiceRecordingConfig = const VoiceRecordingConfiguration();
@@ -67,7 +67,10 @@ class _WpCustomChatBarState extends State<WpCustomChatBar> {
6767
padding: const EdgeInsets.fromLTRB(8, 8, 7.5, 7.5),
6868
decoration: const BoxDecoration(
6969
border: Border(
70-
left: BorderSide(color: AppColors.uiTwoReplyLineColor, width: 4),
70+
left: BorderSide(
71+
color: AppColors.uiTwoReplyLineColor,
72+
width: 4,
73+
),
7174
),
7275
),
7376
child: Row(
@@ -258,10 +261,10 @@ class _WpCustomChatBarState extends State<WpCustomChatBar> {
258261
onPressed: _sendMessage,
259262
padding: EdgeInsets.zero,
260263
style: IconButton.styleFrom(
261-
backgroundColor: AppColors.uiTwoGreen,
264+
backgroundColor:
265+
AppColors.uiTwoGreen,
262266
),
263-
icon:
264-
SvgPicture.asset(AppIcons.send),
267+
icon: SvgPicture.asset(AppIcons.send),
265268
),
266269
),
267270
]
@@ -303,8 +306,8 @@ class _WpCustomChatBarState extends State<WpCustomChatBar> {
303306
child: IconButton(
304307
onPressed: _recordOrStop,
305308
padding: EdgeInsets.zero,
306-
icon: SvgPicture.asset(
307-
AppIcons.mic),
309+
icon:
310+
SvgPicture.asset(AppIcons.mic),
308311
),
309312
),
310313
],

lib/src/widgets/chat_view_list/auto_animate_sliver_list.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ class AutoAnimateSliverListState<T> extends State<AutoAnimateSliverList<T>>
167167
void dispose() {
168168
_updateSubscription?.cancel();
169169
_updateSubscription = null;
170+
_controller.disposeAnimations();
170171
super.dispose();
171172
}
172173
}

0 commit comments

Comments
 (0)