preferredSize property
The size this widget would prefer if it were otherwise unconstrained.
In many cases it's only necessary to define one preferred dimension.
For example the Scaffold only depends on its app bar's preferred
height. In that case implementations of this method can just return
Size.fromHeight(myAppBarHeight).
Implementation
@override
Size get preferredSize {
// Base pill height. The searchable variant alternates between barHeight
// (expanded) and searchBarHeight (inline/mini) — use whichever is active.
// Both branches multiply verticalPadding by 2 (top + bottom) to match
// the symmetric Padding applied inside AdaptiveLiquidGlassLayer.
final effectivePillH =
(_placement == _GlassTabBarPlacement.searchable && isSearchActive)
? searchBarHeight + verticalPadding * 2
: barHeight + verticalPadding * 2;
double total = effectivePillH;
// In inline mode the accessory sits BESIDE the pill (no extra height).
// Only explicit .inline placement counts — never auto-infer from search state,
// because the layout engine (TabBarSearchableLayout) does NOT auto-collapse either.
final isInline =
bottomAccessoryPlacement == GlassTabBarAccessoryPlacement.inline;
if (bottomAccessory != null &&
!isInline &&
bottomAccessoryEnabled &&
bottomAccessoryHeight != null) {
// Guard: gapAdjustment only makes sense in the searchable placement when
// both heights differ. For .bottom placement isSearchActive is always false
// so effectivePillH == barHeight + vertPad*2 and gapAdjustment == 0.
final gapAdjustment =
(_placement == _GlassTabBarPlacement.searchable && isSearchActive)
? barHeight - searchBarHeight
: 0.0;
total = effectivePillH -
gapAdjustment +
bottomAccessorySpacing +
bottomAccessoryHeight!;
}
return Size.fromHeight(total);
}