Skip to content

fix: disabled Radio and CupertinoRadio - #6769

Merged
FeodorFitsner merged 3 commits into
mainfrom
fix/disabled-radio
Aug 14, 2026
Merged

fix: disabled Radio and CupertinoRadio#6769
FeodorFitsner merged 3 commits into
mainfrom
fix/disabled-radio

Conversation

@ndonkoHenri

@ndonkoHenri ndonkoHenri commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

disabled=True had almost no effect on Radio and CupertinoRadio: the radio could still be selected and kept its enabled colors — only the label grayed out (and for Radio, only when a custom label_style was set).

This regressed in the migration to Flutter's native RadioGroup widget (#5651). The old code disabled a radio by passing onChanged: null to the Flutter widget, but under the RadioGroup API a radio with a RadioGroup ancestor is interactive unless it gets an explicit enabled: false. Flet never passed it, so taps on the radio went straight to the group registry, bypassing the disabled checks that only guarded the label's own tap handler.

Both controls now pass enabled: !disabled to their Flutter widgets:

  • a disabled radio ignores taps and renders in its disabled colors;
  • fill_color's ControlState.DISABLED value now actually resolves;
  • disabling an ancestor (e.g. the whole RadioGroup) cascades down to its radios;
  • a disabled Radio's label also grays out with the default text style now, not only with a custom label_style.

Fixes #6159

Test code

import flet as ft

def main(page: ft.Page):
    page.add(
        ft.RadioGroup(
            value="one",
            on_change=lambda e: print("changed:", e.data),
            content=ft.Column(
                controls=[
                    ft.Radio(value="one", label="One", disabled=True),
                    ft.Radio(value="two", label="Two", disabled=True),
                    ft.Radio(value="three", label="Three"),
                ],
            ),
        )
    )

ft.run(main)

Before: "One" and "Two" render fully enabled and clicking them selects them.
After: both render grayed out (radio and label) and clicks are ignored; "Three" still works.

Summary by Sourcery

Bug Fixes:

  • Disabled Radio and CupertinoRadio controls now ignore user interaction, cascade disabled state from ancestors, and render using disabled colors including default label styles.

disabled=True had almost no effect on a radio: it stayed fully
selectable and rendered in its enabled colors — only the label grayed
out, and for Radio only when a custom label_style was set. Regressed in
the migration to Flutter's native RadioGroup widget (#5651): the old
code disabled a radio by passing onChanged: null to the Flutter widget,
but under the RadioGroup API a radio with a RadioGroup ancestor is
interactive unless an explicit enabled: false is passed — Flet never
passed it, so taps on the radio went straight to the group registry,
bypassing Flet's disabled checks, which only guarded the label's own
tap handler.

Both controls now forward enabled: !disabled, so a disabled radio
ignores taps and renders its disabled state (fill_color's
ControlState.DISABLED value now actually resolves too), and disabling
an ancestor (e.g. the whole RadioGroup) cascades the same way. The
Radio label now also grays out with the default text style, not just
with a custom label_style.

@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 ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Aug 13, 2026

Copy link
Copy Markdown

Deploying flet-website-v2 with  Cloudflare Pages  Cloudflare Pages

Latest commit: b8a09a7
Status: ✅  Deploy successful!
Preview URL: https://544274e2.flet-website-v2.pages.dev
Branch Preview URL: https://fix-disabled-radio.flet-website-v2.pages.dev

View logs

@ndonkoHenri ndonkoHenri changed the title fix: disabledRadio and CupertinoRadio fix: disabled Radio and CupertinoRadio Aug 13, 2026
@FeodorFitsner
FeodorFitsner merged commit 9a3d0f3 into main Aug 14, 2026
104 of 107 checks passed
@FeodorFitsner
FeodorFitsner deleted the fix/disabled-radio branch August 14, 2026 16:59
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.

feature: make it possible to disable a radio button

2 participants