LGButton class

A beautiful glass morphism button with organic animations and touch effects.

LGButton brings your UI to life with liquid glass visuals, satisfying squash and stretch animations, and responsive glow effects that react to touch. The button can work in grouped mode (sharing glass settings with other elements) or standalone mode (with its own independent glass layer). Supports both icon buttons and custom content through the LGButton.custom constructor.

Inheritance

Constructors

LGButton({required IconData? icon, required VoidCallback onTap, Key? key, String label = '', double width = 56, double height = 56, double iconSize = 24.0, Color iconColor = Colors.white, LiquidShape shape = const LiquidOval(), LiquidGlassSettings? settings, bool useOwnLayer = false, LGQuality quality = LGQuality.standard, double interactionScale = 1.05, double stretch = 0.5, double resistance = 0.08, HitTestBehavior stretchHitTestBehavior = HitTestBehavior.opaque, Color glowColor = Colors.white24, double glowRadius = 1.0, HitTestBehavior glowHitTestBehavior = HitTestBehavior.opaque, bool enabled = true, LGButtonStyle style = LGButtonStyle.filled})
Creates a glass button with an icon.
const
LGButton.custom({required Widget? child, required VoidCallback onTap, Key? key, String label = '', double width = 56, double height = 56, LiquidShape shape = const LiquidOval(), LiquidGlassSettings? settings, bool useOwnLayer = false, LGQuality quality = LGQuality.standard, double interactionScale = 1.05, double stretch = 0.5, double resistance = 0.08, HitTestBehavior stretchHitTestBehavior = HitTestBehavior.opaque, Color glowColor = Colors.white24, double glowRadius = 1.0, HitTestBehavior glowHitTestBehavior = HitTestBehavior.opaque, bool enabled = true, LGButtonStyle style = LGButtonStyle.filled})
Creates a glass button with custom content.
const

Properties

child Widget?
Custom widget to display in the button.
final
enabled bool
Whether the button is enabled.
final
glowColor Color
The color of the glow effect.
final
glowHitTestBehavior HitTestBehavior
The hit test behavior for the glow gesture listener.
final
glowRadius double
The radius of the glow effect relative to the layer's shortest side.
final
hashCode int
The hash code for this object.
no setterinherited
height double
Height of the button in logical pixels.
final
icon IconData?
The icon to display in the button.
final
iconColor Color
Color of the icon (only used when icon is provided).
final
iconSize double
Size of the icon (only used when icon is provided).
final
interactionScale double
The scale factor to apply when the user is interacting with the button.
final
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
label String
Semantic label for accessibility.
final
onTap VoidCallback
Callback when the button is tapped.
final
quality LGQuality
Rendering quality for the glass effect.
final
resistance double
The resistance factor to apply to the drag offset.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
settings LiquidGlassSettings?
Glass effect settings (only used when useOwnLayer is true).
final
shape LiquidShape
Shape of the glass button.
final
stretch double
The factor to multiply the drag offset by to determine the stretch amount.
final
stretchHitTestBehavior HitTestBehavior
The hit test behavior for the stretch gesture listener.
final
style LGButtonStyle
The visual style of the button.
final
useOwnLayer bool
Whether to create its own layer or use grouped glass within an existing layer.
final
width double
Width of the button in logical pixels.
final

Methods

build(BuildContext context) Widget
Describes the part of the user interface represented by this widget.
override
createElement() StatelessElement
Creates a StatelessElement to manage this widget's location in the tree.
inherited
debugDescribeChildren() List<DiagnosticsNode>
Returns a list of DiagnosticsNode objects describing this node's children.
inherited
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep.
inherited
toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) String
A string representation of this object.
inherited
toStringDeep({String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) String
Returns a string representation of this node and its descendants.
inherited
toStringShallow({String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) String
Returns a one-line detailed description of the object.
inherited
toStringShort() String
A short, textual description of this widget.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited