GlassSegment class
Configuration for a single segment in GlassSegmentedControl.
GlassSegment is the item type for GlassSegmentedControl — the iOS 26
UISegmentedControl equivalent. It intentionally carries only fields
that make sense for a segmented control item:
- label — the text label
- icon — the leading icon (before the label)
- tooltip — tooltip shown on long-press
- semanticLabel — overrides the accessibility announcement
- enabled — whether this segment can be selected
Why not GlassTab?
GlassTab is the navigation-tab type for GlassTabBar.bottom and GlassTabBar.searchable. It carries fields like GlassTab.glowColor, GlassTab.activeIcon, and GlassTab.thickness that are navigation-specific and have no effect in a segmented control. GlassSegment is the correct, minimal API for GlassSegmentedControl.
Usage
GlassSegmentedControl(
segments: [
GlassSegment(label: 'All'),
GlassSegment(label: 'Photos', icon: Icon(CupertinoIcons.photo)),
GlassSegment(label: 'Videos', icon: Icon(CupertinoIcons.video_camera)),
],
selectedIndex: _index,
onSegmentSelected: (i) => setState(() => _index = i),
)
Icon-only segments
GlassSegment(icon: Icon(CupertinoIcons.list_bullet))
GlassSegment(icon: Icon(CupertinoIcons.square_grid_2x2))
Disabled segment
GlassSegment(label: 'Pro Only', enabled: false)
Constructors
Properties
- enabled → bool
-
Whether this segment can be selected.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- icon → Widget?
-
Icon widget to display before the label (or alone, if label is null).
final
- id → Object?
-
Stable identity for this segment across list changes.
final
- label → String?
-
Text label for this segment.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- semanticLabel → String?
-
Overrides the default accessibility announcement.
final
- tooltip → String?
-
Tooltip shown on long-press (optional).
final
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited