Skip to content

Fix icon-only Button rendering an error box and prepare 1.0.2 - #6889

Merged
FeodorFitsner merged 3 commits into
mainfrom
fix-icon-only-button
Sep 25, 2026
Merged

FeodorFitsner merged 3 commits into
mainfrom
fix-icon-only-button

Conversation

@FeodorFitsner

@FeodorFitsner FeodorFitsner commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Fix #6886

Problem

The Python API accepts Button(icon=...) without content, but the Flutter renderer always used the .icon(...) constructors when icon was set, with label: 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 both icon and content are set. Otherwise, build the plain button with whichever one is set as its child, so an icon-only button shows the icon centered. icon_color still applies. Applies to Button, FilledButton, FilledTonalButton, OutlinedButton and TextButton.
  • Removed the unused error widget.

Tests

  • Added a test_icon_only golden test (macOS) for each of the five button types. The test covers the default icon color and a custom icon_color.
  • All 13 tests in the five button test files pass.

Release prep

  • flet Dart package bumped to 1.0.2 (pubspec.yaml, client/pubspec.lock).
  • Added 1.0.2 sections 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:

  • Fix icon-only Button, FilledButton, FilledTonalButton, OutlinedButton, and TextButton controls rendering an error box; icons now render centered when no content is provided.

Build:

  • Bump the flet Dart package to version 1.0.2.

Tests:

  • Add screenshot coverage for icon-only material buttons with default and custom icon colors.

Chores:

  • Update the root and package changelogs for the 1.0.2 release.

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

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

Deploying flet-website-v2 with  Cloudflare Pages  Cloudflare Pages

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

View logs

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

@FeodorFitsner
FeodorFitsner merged commit 4f66f78 into main Sep 25, 2026
20 of 113 checks passed
@FeodorFitsner
FeodorFitsner deleted the fix-icon-only-button branch September 25, 2026 23:26
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.

bug: Button(icon=...) without content passes validation but renders an error box

2 participants