Skip to content

fix: perf improvements#807

Merged
demchenkoalex merged 2 commits intomainfrom
fix/perf-improvements
Jun 8, 2025
Merged

fix: perf improvements#807
demchenkoalex merged 2 commits intomainfrom
fix/perf-improvements

Conversation

@demchenkoalex
Copy link
Copy Markdown
Member

No description provided.

@demchenkoalex
Copy link
Copy Markdown
Member Author

bugbot run

cursor[bot]

This comment was marked as outdated.

@demchenkoalex
Copy link
Copy Markdown
Member Author

Bug: Send Icon Color Parameter Inverted

It's fine since it is a new API, not public facing - I want it inverted.

@demchenkoalex
Copy link
Copy Markdown
Member Author

bugbot run

Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Send Icon Inconsistency

The send icon's visual state is inconsistent with its functional behavior. The onChanged callback now uses value.trim().isNotEmpty to determine if the text field has content, which affects the send icon's color (making it appear disabled for whitespace-only input). However, the send functionality, triggered by _handleSubmitted, still uses the untrimmed text, allowing messages consisting solely of whitespace to be sent despite the icon's disabled appearance.

packages/flutter_chat_ui/lib/src/composer.dart#L274-L340

onChanged: (value) {
_hasTextNotifier.value = value.trim().isNotEmpty;
},
textInputAction: widget.textInputAction,
keyboardAppearance: widget.keyboardAppearance,
autocorrect: widget.autocorrect ?? true,
autofocus: widget.autofocus,
textCapitalization: widget.textCapitalization,
keyboardType: widget.keyboardType,
focusNode: _focusNode,
maxLength: widget.maxLength,
minLines: widget.minLines,
maxLines: widget.maxLines,
),
),
SizedBox(width: widget.gap),
widget.sendIcon != null
? ValueListenableBuilder<bool>(
valueListenable: _hasTextNotifier,
builder: (context, hasText, child) {
final iconColor =
hasText
? (widget.sendIconColor ??
theme.onSurface.withValues(alpha: 0.5))
: (widget.emptyFieldSendIconColor ??
widget.sendIconColor ??
theme.onSurface.withValues(alpha: 0.5));
return IconButton(
icon: widget.sendIcon!,
color: iconColor,
onPressed:
() => _handleSubmitted(_textController.text),
);
},
)
: const SizedBox.shrink(),
],
),
),
],
),
),
),
);
}
void _measure() {
if (!mounted) return;
final renderBox = _key.currentContext?.findRenderObject() as RenderBox?;
if (renderBox != null) {
final height = renderBox.size.height;
final bottomSafeArea = MediaQuery.of(context).padding.bottom;
context.read<ComposerHeightNotifier>().setHeight(
// only set real height of the composer, ignoring safe area
widget.handleSafeArea == true ? height - bottomSafeArea : height,
);
}
}
void _handleSubmitted(String text) {
if (text.isNotEmpty) {
context.read<OnMessageSendCallback?>()?.call(text);
_textController.clear();
}

Fix in Cursor


Was this report helpful? Give feedback by reacting with 👍 or 👎

@demchenkoalex demchenkoalex merged commit 71e6d69 into main Jun 8, 2025
1 check passed
@demchenkoalex demchenkoalex deleted the fix/perf-improvements branch June 8, 2025 15:49
aljanshere pushed a commit to aljanshere/flutter_chat_ui that referenced this pull request Jun 18, 2025
* fix: perf improvements

* fixes after review
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant