Skip to content

feat: add TV focus support for Switch widget - #2326

Open
usmanvrtx wants to merge 1 commit into
scrollbar-focusfrom
tv-switch-focus
Open

feat: add TV focus support for Switch widget#2326
usmanvrtx wants to merge 1 commit into
scrollbar-focusfrom
tv-switch-focus

Conversation

@usmanvrtx

@usmanvrtx usmanvrtx commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Description

This PR adds TV focus support for the Switch widget, allowing it to properly participate in TV focus navigation with a dedicated focus border rendered in the foreground.

Related Issue

N/A

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update
  • Refactoring (no functional changes)

What Has Changed

  • Added paintFocusBorderInForeground option to _TVFocusOnlyWrapper to render focus border using foregroundDecoration instead of decoration
  • Created TVFocusOnlyBoxWrapper as a reusable StatelessWidget for wrapping any widget with TV focus support
  • Added wrapTVFocus parameter to InputWrapper to prevent double TV focus wrapping when the child already handles it
  • Implemented _TVSwitchControl and _SwitchTVFocusBoxController for TV-focused switch rendering with proper focus border

How to Test

  1. Run the app on a TV platform or TV emulator
  2. Navigate to a Switch widget using the remote/d-pad
  3. Verify the switch receives focus with a visible focus border painted in the foreground
  4. Verify the toggle action still works correctly when focused

Screenshots / Videos

N/A

Checklist

  • I have run flutter analyze and addressed any new warnings
  • I have run flutter test and all tests pass
  • I have tested my changes on the relevant platform(s)
  • I have updated documentation if needed
  • My changes do not introduce new warnings or errors

@usmanvrtx
usmanvrtx requested a review from TheNoumanDev July 27, 2026 02:29
@usmanvrtx usmanvrtx self-assigned this Jul 27, 2026
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