HappySlider class

A customizable slide-to-confirm widget that provides a smooth sliding interaction.

The HappySlider allows users to slide a button from left to right to confirm an action. It supports extensive customization including colors, text, icons, and button content.

Example usage:

HappySlider(
  width: 300,
  height: 60,
  text: 'Slide to confirm',
  onSlideComplete: () => print('Slide completed!'),
)
Inheritance

Constructors

HappySlider({Key? key, required double width, required double height, required VoidCallback onSlideComplete, Color borderColor = Colors.grey, Color buttonColor = Colors.orange, Color backgroundColor = Colors.transparent, double borderWidth = 2.0, String text = 'Slide to confirm', TextStyle? textStyle, TextStyle? buttonTextStyle, double borderRadius = 25.0, double sliderWidth = 160, Widget? sliderButton, String? buttonText, Widget? buttonIcon, double? buttonIconSpacing = 14.0, bool showDefaultIcon = true, Color? defaultIconColor = Colors.black, double? defaultIconSize = 24.0, MainAxisAlignment buttonContentAlignment = MainAxisAlignment.center, CrossAxisAlignment buttonCrossAxisAlignment = CrossAxisAlignment.center})
const

Properties

backgroundColor → Color
Background color of the slider container
final
borderColor → Color
Color of the widget border
final
borderRadius → double
Border radius for rounded corners
final
borderWidth → double
Width of the border stroke
final
buttonColor → Color
Background color of the slider button
final
buttonContentAlignment → MainAxisAlignment
Horizontal alignment of button content
final
buttonCrossAxisAlignment → CrossAxisAlignment
Vertical alignment of button content
final
buttonIcon → Widget?
Custom icon to display on the slider button
final
buttonIconSpacing → double?
Spacing between button text and icon
final
buttonText → String?
Text to display on the slider button
final
buttonTextStyle → TextStyle?
Style for the button text (when using buttonText)
final
defaultIconColor → Color?
Color of the default arrow icon
final
defaultIconSize → double?
Size of the default arrow icon
final
hashCode → int
The hash code for this object.
no setterinherited
height → double
Height of the slider widget
final
key → Key?
Controls how one widget replaces another widget in the tree.
finalinherited
onSlideComplete → VoidCallback
Callback function executed when slide is completed (reaches threshold)
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
showDefaultIcon → bool
Whether to show the default arrow icon when no custom icon is provided
final
sliderButton → Widget?
Custom widget to replace the entire slider button content
final
sliderWidth → double
Width of the draggable slider button
final
text → String
Text displayed in the background of the slider
final
textStyle → TextStyle?
Style for the background text
final
width → double
Total width of the slider widget
final

Methods

createElement() → StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
inherited
createState() → State<HappySlider>
Creates the mutable state for this widget at a given location in the tree.
override
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