Skip to content

Commit 6e312f5

Browse files
Refactor ChatMessageBubble: Remove unnecessary TextEditingController
1 parent 0c7edd7 commit 6e312f5

File tree

1 file changed

+11
-20
lines changed

1 file changed

+11
-20
lines changed

lib/data/view/chat/widgets/chat_message_bubble.dart

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ class ChatMessageBubble extends StatefulWidget {
2222

2323
class _ChatMessageBubbleState extends State<ChatMessageBubble> {
2424
bool _showFullText = false;
25-
final _textController = TextEditingController();
2625

2726
@override
2827
void initState() {
@@ -32,12 +31,6 @@ class _ChatMessageBubbleState extends State<ChatMessageBubble> {
3231
}
3332
}
3433

35-
@override
36-
void dispose() {
37-
_textController.dispose();
38-
super.dispose();
39-
}
40-
4134
@override
4235
Widget build(BuildContext context) {
4336
return Column(
@@ -147,23 +140,21 @@ class _ChatMessageBubbleState extends State<ChatMessageBubble> {
147140
)
148141
else
149142
TypeWriterText(
150-
controller: _textController,
151-
builder: (context, value) {
152-
return Text(
153-
value,
154-
style: const TextStyle(
155-
color: Color(0xFFD1D5DB),
156-
fontSize: 16,
157-
),
158-
);
159-
},
160-
onComplete: () {
143+
maintainSize: true,
144+
repeat: false,
145+
text: Text(
146+
text,
147+
style: const TextStyle(
148+
color: Color(0xFFD1D5DB),
149+
fontSize: 16,
150+
),
151+
),
152+
duration: const Duration(milliseconds: 30),
153+
onEnd: () {
161154
setState(() {
162155
_showFullText = true;
163156
});
164157
},
165-
text: Text(text),
166-
duration: const Duration(milliseconds: 30),
167158
),
168159
if (!isUser) ...[
169160
const Divider(color: Color(0xFF4D4D4D)),

0 commit comments

Comments
 (0)