GlassToggle.button constructor
const
GlassToggle.button({
- required bool value,
- required ValueChanged<
bool> ? onChanged, - Key? key,
- String? label,
- Widget? icon,
- Widget? child,
- Color? activeColor,
- Color? foregroundColor,
- Color? activeForegroundColor,
- TextStyle? labelStyle,
- double iconSize = 17.0,
- double spacing = 6.0,
- EdgeInsetsGeometry? padding,
- double minHeight = 34.0,
- double? width,
- double? height,
- LiquidShape shape = const LiquidRoundedSuperellipse(borderRadius: 100),
- GlassSurfaceStyle? surfaceStyle,
- Color? color,
- LiquidGlassSettings? settings,
- bool useOwnLayer = false,
- GlassQuality? quality,
- bool platformViewBackdrop = false,
- bool enableHaptics = true,
- double? interactionScale,
- double stretch = 0.3,
- double? glowRadius,
- bool anchorStretch = true,
- AnchorStretchSettings? anchorStretchSettings,
- FocusNode? focusNode,
- bool autofocus = false,
- bool canRequestFocus = true,
- String? semanticLabel,
- bool semanticsInMutuallyExclusiveGroup = false,
- TextDirection? textDirection,
Creates a capsule toggle button matching SwiftUI Toggle(.button).
At least one of label, icon, or child must be provided. child
cannot be combined with label or icon.
Implementation
const GlassToggle.button({
required this.value,
required this.onChanged,
super.key,
this.label,
this.icon,
this.child,
this.activeColor,
this.foregroundColor,
this.activeForegroundColor,
this.labelStyle,
this.iconSize = 17.0,
this.spacing = 6.0,
this.padding,
this.minHeight = 34.0,
this.width,
this.height,
this.shape = const LiquidRoundedSuperellipse(borderRadius: 100),
this.surfaceStyle,
this.color,
this.settings,
this.useOwnLayer = false,
this.quality,
this.platformViewBackdrop = false,
this.enableHaptics = true,
this.interactionScale,
this.stretch = 0.3,
this.glowRadius,
this.anchorStretch = true,
this.anchorStretchSettings,
this.focusNode,
this.autofocus = false,
this.canRequestFocus = true,
this.semanticLabel,
this.semanticsInMutuallyExclusiveGroup = false,
this.textDirection,
}) : assert(
child != null || label != null || icon != null,
'GlassToggle.button requires at least one of label, icon, or child.',
),
assert(
child == null || (label == null && icon == null),
'GlassToggle.button cannot combine child with label or icon.',
);