Fix icon-only Button rendering an error box and prepare 1.0.2 - #6889
Merged
Merged
Conversation
Build the plain button with the icon as its child when icon is set without content, instead of the .icon() constructors that require a label. Applies to Button, FilledButton, FilledTonalButton, OutlinedButton and TextButton. Fix #6886
Deploying flet-website-v2 with
|
| Latest commit: |
0de4ffb
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://723ed229.flet-website-v2.pages.dev |
| Branch Preview URL: | https://fix-icon-only-button.flet-website-v2.pages.dev |
Contributor
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The implementation matches the documented API contract and includes complete visual regression coverage.
Review effort: Balanced
Findings: None
What changed in this PR
Fixes icon-only Material buttons and prepares the Dart package for release 1.0.2.
Changes:
- Render icon-only buttons with centered icons and preserve
icon_color. - Add golden coverage for all five affected button variants.
- Update package versions and changelogs.
| File | Description |
|---|---|
CHANGELOG.md |
Documents the user-facing fix. |
client/pubspec.lock |
Locks flet to 1.0.2. |
packages/flet/CHANGELOG.md |
Documents the Dart renderer change. |
packages/flet/lib/src/controls/button.dart |
Corrects icon-only rendering. |
packages/flet/pubspec.yaml |
Bumps the package to 1.0.2. |
.../golden/macos/button/icon_only.png |
Adds Button golden output. |
.../golden/macos/filled_button/icon_only.png |
Adds FilledButton golden output. |
.../golden/macos/filled_tonal_button/icon_only.png |
Adds tonal-button golden output. |
.../golden/macos/outlined_button/icon_only.png |
Adds outlined-button golden output. |
.../golden/macos/text_button/icon_only.png |
Adds text-button golden output. |
.../material/test_button.py |
Tests icon-only Button. |
.../material/test_filled_button.py |
Tests icon-only FilledButton. |
.../material/test_filled_tonal_button.py |
Tests icon-only tonal buttons. |
.../material/test_outlined_button.py |
Tests icon-only outlined buttons. |
.../material/test_text_button.py |
Tests icon-only text buttons. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix #6886
Problem
The Python API accepts
Button(icon=...)withoutcontent, but the Flutter renderer always used the.icon(...)constructors wheniconwas set, withlabel: content ?? error. As a result, icon-only buttons rendered an "Error displaying Button" box.Fix
packages/flet/lib/src/controls/button.dart: use the.icon(...)constructors only when bothiconandcontentare set. Otherwise, build the plain button with whichever one is set as its child, so an icon-only button shows the icon centered.icon_colorstill applies. Applies toButton,FilledButton,FilledTonalButton,OutlinedButtonandTextButton.Tests
test_icon_onlygolden test (macOS) for each of the five button types. The test covers the default icon color and a customicon_color.Release prep
fletDart package bumped to1.0.2(pubspec.yaml,client/pubspec.lock).1.0.2sections to the root and package changelogs.Summary by Sourcery
Render material buttons correctly when configured with an icon but no content and prepare the Dart package for the 1.0.2 release.
Bug Fixes:
Build:
Tests:
Chores: