indicator_tab_bar 1.1.0
indicator_tab_bar: ^1.1.0 copied to clipboard
A fixed-width tab indicator that underlines the label rather than the tab, and a sliver AnimatedSwitcher for cross-fading the body each tab selects.
Changelog #
1.1.0 #
LineTabIndicator.alignment— where the bar sits inside the tab. It still defaults toAlignment.bottomCenter, so nothing moves unless you ask;Alignment.topCentermakes it an overline for aTabBarbelow what it selects, andAlignmentDirectional.bottomStarttucks it under the leading edge of the label and flips with the reading direction.LineTabIndicator.insets— deflates the rect the bar is aligned within, so an underline can be lifted clear of the bottom edge and let theTabBardivider show beneath it.LineTabIndicator.gradientconstructor — fills the bar with aGradientinstead of a flat colour. The gradient is laid out across the bar itself, not across the tab, so it runs over exactlyindicatorWidthlogical pixels, and its shader is rebuilt only when the bar moves.hitTest,getClipPathand painting now resolveTextDirection, falling back toTextDirection.ltrfor callers that have none to give.- A null side of
lerpnow fades the fill towards transparent without moving the bar, gradients included, instead of lerping the colour alone. copyWith,==,hashCodeanddebugFillPropertiescover the new fields.
1.0.0 #
- First release.
LineTabIndicator— aTabBar.indicatordecoration that draws a bar of a fixedindicatorWidth, centred on the bottom edge of the tab, rather than one sized to the tab or to its label. A tab narrower than the bar gets one that overhangs it evenly.- The bar is a rounded rectangle
strokeWidthtall and exactlyindicatorWidthwide, withradiusclamped tostrokeWidth / 2— past half the height the ends are already semicircles and there is nothing left to round. - Value semantics:
==,hashCode,copyWith,debugFillProperties, andlerpFrom/lerpToover every field, so the indicator animates across a theme change and a rebuild that changes nothing does not repaint. hitTestandgetClipPathdescribe the bar itself, not the whole rect it was laid out in.SliverAnimatedSwitcher— anAnimatedSwitcherfor slivers, for a tab body living in aCustomScrollView. The plain one stacks its children in aStackand wraps them in box transitions, neither of which a sliver survives.- Only the incoming sliver animates: slivers cannot be overlaid, so the
outgoing one is dropped as the swap begins.
switchOutCurveandreverseDurationare deliberately absent rather than present and inert. transitionBuilderfor a transition other than the defaultSliverFadeTransition.- No Material import anywhere in
lib/.TabBar.indicatortakes a plainDecoration, so the indicator serves aTabBarfrompackage:flutter/material.dartand one from thematerial_uifork alike. - README images are generated from the real widgets by
example/test/screenshots_test.dart.
