tab_overview library

A tab switcher for Flutter: the tabs your app keeps open show as live thumbnails in a grid, and a tap zooms one into a full page.

Flutter's TabBar shows a row of tab labels, and its TabBarView swipes between their pages. A TabOverview shows multiple tabs at once, each as a thumbnail of its page, for tabs that people add, close and reorder as they go, such as documents, chats or forms:

  • Zoom a thumbnail into its page and back, with a hero animation within the same page, from hero_here, along a curve or, with TabTransition.spring, on a spring. With TabOverview.pullToCollapse, a pull down zooms a page back out too.
  • Swipe between the pages of the open tabs.
  • Drag and drop a thumbnail to reorder the tabs, from animated_reorderable.
  • Close a tab with its close button, a RemoveTabButton by default, or by swiping its thumbnail away, and add tabs with TabOverviewController.add.
  • Build thumbnails of your own with TabOverview.tabThumbnailBuilder, around a FittedTab, which scales a tab's page down to its cell, or as cards whose parts, such as a title, fly to their places on the page in TabHeros.

Give a TabOverviewController your tabs, and build their pages in TabOverview.builder:

final controller = TabOverviewController<int>(initialTabs: [1, 2, 3]);

TabOverview<int>.builder(
  controller: controller,
  tabBuilder: (context, tab) => GestureDetector(
    onTap: () => controller.isTabExpanded(tab)
        ? controller.collapse()
        : controller.expand(tab),
    child: Center(child: Text('Tab $tab')),
  ),
)

Classes

FittedTab
Lays child out at the size of the TabOverview it's in, and scales it to the width of the space it's given, cropping what doesn't fit, as the default tabThumbnailBuilder does with each tab's content.
RemoveTabButton
The close button the overview shows on a tab by default, at its top right corner, which removes the tab. Use it in a removeTabButtonBuilder to keep its look and do something else when it's pressed, such as asking first.
TabDecorations
Ready-made builders of a tab's decoration, for TabOverview.tabDecorationBuilder.
TabHero
A part of a tab, such as its title or its latest message, that flies on its own between the tab's thumbnail and its page as the tab zooms in and out: a hero animation of its own, in step with the tab's.
TabOverview<T>
A tab switcher: the tabs a TabOverviewController holds show as live thumbnails in a grid, and TabOverviewController.expand zooms one into a full page, where a swipe turns to the next tab.
TabOverviewController<T>
Holds a TabOverview's tabs, its active tab, and whether it shows them as a grid of thumbnails or the active tab as a full page: its mode.
TabTransition
How long one of the overview's animations takes, and how it eases, or the spring it runs on.
TabZoom
Where a tab is on its way between its thumbnail and its page.

Enums

TabOverviewMode
Whether a TabOverview shows its tabs as a grid of thumbnails, or the active tab as a full page.
TabZoomDirection
Which way a tab zooms.

Typedefs

ActiveTabChangedListener = VoidCallback
Called as another tab, or none, becomes a TabOverviewController's active tab.
HeldThumbnailBuilder<T> = Widget Function(BuildContext context, T tab, Widget thumbnail, Animation<double> animation)
Builds a thumbnail in the grid, with its close button, as it looks while it's held to be moved, around thumbnail, from animation, which runs from 0 to 1 as the thumbnail is picked up and back to 0 as it's let go.
ModeChangedListener = void Function(TabOverviewMode mode)
Called with a TabOverviewController's new mode as it changes.
ModelWidgetBuilder<T> = Widget Function(BuildContext context, T model)
Builds a widget for a tab, model: its page in tabBuilder, its thumbnail in tabThumbnailBuilder, or its close button in removeTabButtonBuilder.
TabAddedListener<T> = void Function(T tab)
Called with a tab added to a TabOverviewController.
TabDecorationBuilder<T> = Decoration Function(BuildContext context, T tab, Decoration decoration, TabZoom zoom)
Builds a tab's decoration as its thumbnail rests in the grid, as its page shows, as it zooms between the two, and as its page is pulled down, from decoration, the one between the overview's thumbnailDecoration and expandedTabDecoration where the tab is, which it may give back as it is, change or replace. The tab clips to what it returns.
TabRemovedListener<T> = void Function(T removedTab)
Called with a tab removed from a TabOverviewController, by TabOverviewController.remove or TabOverviewController.removeAt, which the default close button and a swipe call too.
TabsReorderedListener = VoidCallback
Called as the user drags a tab to a new place among a TabOverviewController's tabs.