GlassSegmentedControl constructor

const GlassSegmentedControl({
  1. required List<String> segments,
  2. required int selectedIndex,
  3. required ValueChanged<int> onSegmentSelected,
  4. Key? key,
  5. double height = GlassDefaults.heightControl,
  6. double borderRadius = GlassDefaults.borderRadius,
  7. EdgeInsetsGeometry padding = const EdgeInsets.all(2),
  8. TextStyle? selectedTextStyle,
  9. TextStyle? unselectedTextStyle,
  10. Color? backgroundColor,
  11. Color? indicatorColor,
  12. LiquidGlassSettings? indicatorSettings,
  13. LiquidGlassSettings? glassSettings,
  14. bool useOwnLayer = false,
  15. GlassQuality quality = GlassQuality.standard,
  16. GlobalKey<State<StatefulWidget>>? backgroundKey,
})

Creates a glass segmented control.

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.glassSettings,
  this.useOwnLayer = false,
  this.quality = GlassQuality.standard,
  this.backgroundKey,
})  : assert(
        segments.length >= 2,
        'GlassSegmentedControl requires at least 2 segments',
      ),
      assert(
        selectedIndex >= 0 && selectedIndex < segments.length,
        'selectedIndex must be within bounds of segments list',
      );