Skip to content

Conversation

@ndonkoHenri
Copy link
Contributor

@ndonkoHenri ndonkoHenri commented Dec 14, 2025

Fix #5599

Summary by Sourcery

Improve tab rendering and per-control theming by centralizing control context handling and aligning Tabs with Flutter's Tab heuristics.

New Features:

  • Add a reusable control context wrapper that combines control reactivity and per-control theming for all controls.
  • Expose a Control extension method to build widgets within the standardized control context.

Bug Fixes:

  • Fix inconsistent Tab display by ensuring TabBar sees tab widgets as Tab instances and by aligning icon/text hints and sizing behavior.

Enhancements:

  • Refactor ControlWidget to use the new control context helper, simplifying widget construction and theme application.
  • Introduce a TabControl that extends Flutter's Tab to provide better integration with TabBar sizing and icon/label heuristics while still using Flet controls for content.
  • Ensure TabBar tabs created from arbitrary controls are wrapped in Tab widgets for consistent hover and splash behavior.
  • Add per-control theme resolution that respects theme, dark_theme, and theme_mode properties, falling back to the parent theme and system brightness as appropriate.

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

We've reviewed this pull request using the Sourcery rules engine

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors the Tab control rendering to better integrate with Flutter's TabBar widget while extracting reusable control context and theme utilities.

Key Changes:

  • Extracted control context/theme logic from ControlWidget into reusable withControlNotifier, withControlContext, and withControlTheme functions
  • Modified TabControl to extend Tab and provide size hints to Flutter's TabBar while building custom content
  • Enhanced tab building in TabBarControl to explicitly handle Tab-type controls vs. arbitrary controls

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
packages/flet/lib/src/widgets/control_inherited_notifier.dart Added reusable utility functions for wrapping widgets with ControlInheritedNotifier and per-control theme support; includes extension method for convenient access
packages/flet/lib/src/controls/tabs.dart Refactored TabControl to extend Tab for proper TabBar integration; improved tab building logic to set notifyParent and handle non-Tab controls
packages/flet/lib/src/controls/control_widget.dart Simplified by delegating to new control context utilities; removed duplicate theme/notifier wrapping logic

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 55 to 63
Widget withControlContext(
Control control,
WidgetBuilder builder,
) {
return Builder(builder: (context) {
final child = withControlNotifier(control, builder);
return withControlTheme(control, context, child);
});
}
Copy link

Copilot AI Dec 14, 2025

Choose a reason for hiding this comment

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

When skip_inherited_notifier is true, the new code path wraps the widget with two Builder widgets (one from withControlContext at line 59, and one from withControlNotifier at line 40), whereas the old code had no wrapper. While Builder widgets are lightweight, this introduces extra widget layers that didn't exist before for controls opting out of the inherited notifier pattern. Consider optimizing withControlContext to avoid the extra Builder when skip_inherited_notifier is true.

Copilot uses AI. Check for mistakes.
@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Dec 14, 2025

Deploying flet-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: 78d2be1
Status: ✅  Deploy successful!
Preview URL: https://849bd354.flet-docs.pages.dev
Branch Preview URL: https://fix-tabs.flet-docs.pages.dev

View logs

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.

v1: Tabs looks wrong compared to Flutter

2 participants