Skip to content

Add useIndexedTab property for smooth tab switching with lazy-loaded indexed building#2190

Open
usmanvrtx wants to merge 1 commit intomainfrom
indexed_tabbar
Open

Add useIndexedTab property for smooth tab switching with lazy-loaded indexed building#2190
usmanvrtx wants to merge 1 commit intomainfrom
indexed_tabbar

Conversation

@usmanvrtx
Copy link
Copy Markdown
Contributor

Description:
Introduces useIndexedTab, a boolean property that enables IndexedStack-based tab building in TabBar widgets.

Problem it solves:
By default, when switching tabs, the previous tab's widget is removed from the widget tree. Switching back to that tab requires rebuilding it, which causes lag or freezing if the tab contains heavy data.

Solution:
With useIndexedTab: true, tabs are built on-demand and cached. When you switch to a tab for the first time, it's built and cached. Tab switching becomes instant—no rebuild, no delay, no freeze. Unvisited tabs remain lazy and are not built until accessed.

How it works:

  • Tabs are built only when first accessed (lazy loading)
  • Built tabs are cached and kept in the widget tree while the screen is active
  • Uses IndexedStack (expanded) or Column with Offstage (non-expanded) to maintain widgets in tree
  • Only the active tab is visible; others remain cached and ready

Impact:
Eliminates freezed transitions when switching between tabs with heavy content.

Screen.Recording.2026-04-28.at.01.10.53.mov

@usmanvrtx usmanvrtx requested a review from TheNoumanDev April 27, 2026 20:12
@usmanvrtx usmanvrtx self-assigned this Apr 27, 2026
Copilot AI review requested due to automatic review settings April 27, 2026 20:12
@usmanvrtx usmanvrtx added the enhancement New feature or request label Apr 27, 2026
@usmanvrtx usmanvrtx review requested due to automatic review settings April 27, 2026 20:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant