Skip to content

Commit 6106433

Browse files
authored
fix: disable send button when field empty (#262)
1 parent 249186e commit 6106433

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

lib/app/modules/chat/presentation/widgets/chat_input.dart

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class _ChatInputState extends State<ChatInput> {
2424
void initState() {
2525
super.initState();
2626
_controller.addListener(() {
27-
setState(() => _filled = _controller.text.isNotEmpty);
27+
setState(() => _filled = _controller.text.trim().isNotEmpty);
2828
});
2929
}
3030

@@ -76,11 +76,15 @@ class _ChatInputState extends State<ChatInput> {
7676
BlendMode.srcIn,
7777
),
7878
),
79-
onPressed: () {
80-
L.c('sendMessage');
81-
context.read<ChatBloc>().add(ChatSendChat(_controller.text));
82-
_controller.clear();
83-
},
79+
onPressed: _filled
80+
? () {
81+
L.c('sendMessage');
82+
context.read<ChatBloc>().add(
83+
ChatSendChat(_controller.text.trim()),
84+
);
85+
_controller.clear();
86+
}
87+
: null,
8488
),
8589
],
8690
),

0 commit comments

Comments
 (0)