GlassSegmentedControl.scrollable constructor
const
GlassSegmentedControl.scrollable({
- required List<
GlassSegment> segments, - required int selectedIndex,
- required ValueChanged<
int> onSegmentSelected, - Key? key,
- double height = 44.0,
- double borderRadius = GlassDefaults.borderRadius,
- EdgeInsetsGeometry padding = const EdgeInsets.all(2),
- TextStyle? selectedTextStyle,
- TextStyle? unselectedTextStyle,
- Color? backgroundColor,
- Color? indicatorColor,
- LiquidGlassSettings? indicatorSettings,
- double indicatorPinchStrength = 0.4,
- EdgeInsetsGeometry indicatorExpansion = const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
- LiquidGlassSettings? settings,
- bool useOwnLayer = false,
- GlassQuality? quality,
- GlobalKey<
State< ? backgroundKey,StatefulWidget> > - double iconSize = 24.0,
- EdgeInsetsGeometry labelPadding = const EdgeInsets.symmetric(horizontal: 16),
- Color? selectedIconColor,
- Color? unselectedIconColor,
- MaskingQuality maskingQuality = MaskingQuality.high,
- DividerSettings? dividerSettings,
- List<
BoxShadow> ? indicatorShadow,
Creates a scrollable glass segmented control that 100% mimics
GlassTabBar(isScrollable: true) from the original API.
Use this when you have many segments (typically 6+) that won’t fit in the available width. Segments have natural widths and scroll horizontally.
GlassSegmentedControl.scrollable(
segments: [
GlassSegment(label: 'All'),
GlassSegment(label: 'Photos', icon: Icon(Icons.photo)),
GlassSegment(label: 'Videos'),
GlassSegment(label: 'Music'),
GlassSegment(label: 'Files'),
],
selectedIndex: _selectedIndex,
onSegmentSelected: (i) => setState(() => _selectedIndex = i),
)
Implementation
const GlassSegmentedControl.scrollable({
required this.segments,
required this.selectedIndex,
required this.onSegmentSelected,
super.key,
this.height = 44.0,
this.borderRadius = GlassDefaults.borderRadius,
this.padding = const EdgeInsets.all(2),
this.selectedTextStyle,
this.unselectedTextStyle,
this.backgroundColor,
this.indicatorColor,
this.indicatorSettings,
this.indicatorPinchStrength = 0.4,
this.indicatorExpansion =
const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
this.settings,
this.useOwnLayer = false,
this.quality,
this.backgroundKey,
// Scrollable-specific params
this.iconSize = 24.0,
this.labelPadding = const EdgeInsets.symmetric(horizontal: 16),
this.selectedIconColor,
this.unselectedIconColor,
this.maskingQuality = MaskingQuality.high,
this.dividerSettings,
this.indicatorShadow,
}) : isScrollable = true,
interactionBehavior = GlassInteractionBehavior.full,
glowColor = null,
glowRadius = 1.5,
assert(segments.length >= 1,
'GlassSegmentedControl.scrollable requires at least 1 segment'),
assert(
selectedIndex >= 0 && selectedIndex < segments.length,
'selectedIndex must be within bounds of segments list',
);