GlassToggle.button constructor

const GlassToggle.button({
  1. required bool value,
  2. required ValueChanged<bool>? onChanged,
  3. Key? key,
  4. String? label,
  5. Widget? icon,
  6. Widget? child,
  7. Color? activeColor,
  8. Color? foregroundColor,
  9. Color? activeForegroundColor,
  10. TextStyle? labelStyle,
  11. double iconSize = 17.0,
  12. double spacing = 6.0,
  13. EdgeInsetsGeometry? padding,
  14. double minHeight = 34.0,
  15. double? width,
  16. double? height,
  17. LiquidShape shape = const LiquidRoundedSuperellipse(borderRadius: 100),
  18. GlassSurfaceStyle? surfaceStyle,
  19. Color? color,
  20. LiquidGlassSettings? settings,
  21. bool useOwnLayer = false,
  22. GlassQuality? quality,
  23. bool platformViewBackdrop = false,
  24. bool enableHaptics = true,
  25. double? interactionScale,
  26. double stretch = 0.3,
  27. double? glowRadius,
  28. bool anchorStretch = true,
  29. AnchorStretchSettings? anchorStretchSettings,
  30. FocusNode? focusNode,
  31. bool autofocus = false,
  32. bool canRequestFocus = true,
  33. String? semanticLabel,
})

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,
})  : 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.',
      );