GlassButton.custom constructor

const GlassButton.custom({
  1. required Widget? child,
  2. required VoidCallback onTap,
  3. Key? key,
  4. String label = '',
  5. double? width,
  6. double? height,
  7. LiquidShape shape = const LiquidOval(),
  8. LiquidGlassSettings? settings,
  9. bool useOwnLayer = false,
  10. GlassQuality? quality,
  11. GlassSurfaceStyle? surfaceStyle,
  12. Color? color,
  13. Color? tintColor,
  14. FocusNode? focusNode,
  15. bool autofocus = false,
  16. double? interactionScale,
  17. double stretch = 0.5,
  18. double resistance = 0.01,
  19. HitTestBehavior stretchHitTestBehavior = HitTestBehavior.opaque,
  20. Color? glowColor,
  21. double? glowRadius,
  22. double? glowBlurRadius,
  23. double? glowSpreadRadius,
  24. double? glowOpacity,
  25. HitTestBehavior glowHitTestBehavior = HitTestBehavior.opaque,
  26. bool enabled = true,
  27. GlassButtonStyle style = GlassButtonStyle.filled,
  28. bool persistPressOnDrag = true,
  29. bool anchorStretch = true,
  30. AnchorStretchSettings? anchorStretchSettings,
  31. AlignmentGeometry alignment = Alignment.center,
  32. double? ambientBaseLight,
  33. Color? pressLightColor,
  34. bool platformViewBackdrop = false,
  35. bool canRequestFocus = true,
  36. bool excludeFromSemantics = false,
  37. bool isStationary = false,
})

Creates a glass button with custom content.

This allows you to use any widget as the button's content instead of just an icon. Useful for text buttons, composite content, etc.

Example:

GlassButton.custom(
  onTap: () {},
  width: 120,
  height: 48,
  child: Row(
    mainAxisAlignment: MainAxisAlignment.center,
    children: [
      Icon(CupertinoIcons.play, size: 16),
      SizedBox(width: 8),
      Text('Play'),
    ],
  ),
)

Implementation

const GlassButton.custom({
  required this.child,
  required this.onTap,
  super.key,
  this.label = '',
  this.width,
  this.height,
  this.shape = const LiquidOval(),
  this.settings,
  this.useOwnLayer = false,
  this.quality,
  this.surfaceStyle,
  this.color,
  this.tintColor,
  this.focusNode,
  this.autofocus = false,
  // LiquidStretch properties
  this.interactionScale,
  this.stretch = 0.5,
  this.resistance = 0.01,
  this.stretchHitTestBehavior = HitTestBehavior.opaque,
  // GlassGlow properties
  this.glowColor,
  this.glowRadius,
  // null → native iOS 26 shape-clipped specular (wide 1.6 radius, sigma-16 blur, soft sheen).
  // 0.0  → opt out; pure ambient lift only.
  // > 0  → custom explicit radius.
  this.glowBlurRadius,
  this.glowSpreadRadius,
  this.glowOpacity,
  this.glowHitTestBehavior = HitTestBehavior.opaque,
  this.enabled = true,
  this.style = GlassButtonStyle.filled,
  this.persistPressOnDrag = true,
  this.anchorStretch = true,
  this.anchorStretchSettings,
  this.alignment = Alignment.center,
  this.ambientBaseLight,
  this.pressLightColor,
  this.platformViewBackdrop = false,
  this.canRequestFocus = true,
  this.excludeFromSemantics = false,
  this.isStationary = false,
})  : icon = null,
      iconSize = 24.0,
      iconColor = null;