GlassSegmentedControl constructor
const
GlassSegmentedControl({
- required List<
GlassSegment> segments, - required int selectedIndex,
- required ValueChanged<
int> onSegmentSelected, - Key? key,
- double height = GlassDefaults.heightControl,
- 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> > - GlassInteractionBehavior interactionBehavior = GlassInteractionBehavior.full,
- Color? glowColor,
- double glowRadius = 1.5,
- bool isScrollable = false,
- 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 fixed-width glass segmented control (iOS UISegmentedControl).
All segments are equal-width. For a scrollable variant that mimics
GlassTabBar(isScrollable: true), use GlassSegmentedControl.scrollable.
Implementation
const GlassSegmentedControl({
required this.segments,
required this.selectedIndex,
required this.onSegmentSelected,
super.key,
this.height = GlassDefaults.heightControl,
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,
// ── iOS 26 interaction ──────────────────────────────────────────────────
this.interactionBehavior = GlassInteractionBehavior.full,
this.glowColor,
this.glowRadius = 1.5,
// Scrollable-mode fields — unused in fixed mode.
this.isScrollable = false,
this.iconSize = 24.0,
this.labelPadding = const EdgeInsets.symmetric(horizontal: 16),
this.selectedIconColor,
this.unselectedIconColor,
this.maskingQuality = MaskingQuality.high,
this.dividerSettings,
this.indicatorShadow,
}) : assert(
segments.length >= 2,
'GlassSegmentedControl requires at least 2 segments',
),
assert(
segments.length <= 6,
'GlassSegmentedControl works best with 2–5 segments. '
'For 6+ items use GlassSegmentedControl.scrollable().',
),
assert(
selectedIndex >= 0 && selectedIndex < segments.length,
'selectedIndex must be within bounds of segments list',
);