IncrementDecrementWidget class

A widget that provides increment and decrement functionality with customizable buttons and display. It allows users to increase or decrease a numerical value within optional bounds, making it suitable for quantity selectors in shopping carts, forms, and other interactive UI components.

The IncrementDecrementWidget offers multiple factory constructors to cater to different design requirements, such as flat, raised, minimal, and squared styles. It also supports long-press actions for continuous incrementing or decrementing.

Inheritance

Constructors

IncrementDecrementWidget({Key? key, required int quantity, int? maxQuantity, int? minValue, ValueUpdate? onChanged, Color? backgroundColor, Color? iconColor, double? elevation, EdgeInsetsGeometry? margin, EdgeInsetsGeometry? valuePadding, TextStyle? quantityTextStyle, double? borderRadius, double? width, double? height, EdgeInsetsGeometry? buttonPadding, EdgeInsetsGeometry? buttonMargin, double? buttonWidth, double? buttonHeight, Color? splashColor, Color? borderColor, double borderWidth = 1.0, InteractiveInkFeatureFactory? splashFactory, Widget? incrementIcon, Widget? decrementIcon, OutlinedBorder? buttonShape, Duration longPressInterval = const Duration(milliseconds: 100), MainAxisAlignment? alignment})
Creates an IncrementDecrementWidget with the specified properties.
const
IncrementDecrementWidget.flat({required int quantity, int? maxQuantity, int? minValue, ValueUpdate? onChanged, Color? backgroundColor, Color? iconColor, EdgeInsetsGeometry? margin, EdgeInsetsGeometry? valuePadding, EdgeInsetsGeometry? buttonMargin, EdgeInsetsGeometry? buttonPadding, TextStyle? quantityTextStyle, double? borderRadius, double? width, double? height, double? buttonWidth, double? buttonHeight, Color? splashColor, Color? borderColor, double borderWidth = 1.0, InteractiveInkFeatureFactory? splashFactory, Widget? incrementIcon, Widget? decrementIcon, Duration longPressInterval = const Duration(milliseconds: 100), MainAxisAlignment? alignment})
Factory constructor for a flat design.
factory
IncrementDecrementWidget.minimal({required int quantity, int? maxQuantity, int? minValue, ValueUpdate? onChanged, Color? iconColor, EdgeInsetsGeometry? margin, EdgeInsetsGeometry? valuePadding, EdgeInsetsGeometry? buttonMargin, EdgeInsetsGeometry? buttonPadding, TextStyle? quantityTextStyle, double? width, double? height, double? buttonWidth, double? buttonHeight, Widget? incrementIcon, Widget? decrementIcon, Duration longPressInterval = const Duration(milliseconds: 100), MainAxisAlignment? alignment})
Factory constructor for a minimalistic design.
factory
IncrementDecrementWidget.raised({required int quantity, int? maxQuantity, int? minValue, ValueUpdate? onChanged, Color? backgroundColor, Color? iconColor, double? elevation, EdgeInsetsGeometry? margin, EdgeInsetsGeometry? valuePadding, EdgeInsetsGeometry? buttonMargin, EdgeInsetsGeometry? buttonPadding, TextStyle? quantityTextStyle, double? borderRadius, double? width, double? height, double? buttonWidth, double? buttonHeight, Color? borderColor, double borderWidth = 1.0, Widget? incrementIcon, Widget? decrementIcon, Duration longPressInterval = const Duration(milliseconds: 100), MainAxisAlignment? alignment})
Factory constructor for a raised design.
factory
IncrementDecrementWidget.squared({required int quantity, int? maxQuantity, int? minValue, ValueUpdate? onChanged, Color? backgroundColor, Color? iconColor, double? elevation, EdgeInsetsGeometry? margin, EdgeInsetsGeometry? valuePadding, EdgeInsetsGeometry? buttonMargin, EdgeInsetsGeometry? buttonPadding, TextStyle? quantityTextStyle, double? width, double? height, double? buttonSize, double? borderRadius, Color? borderColor, double borderWidth = 1.0, Widget? incrementIcon, Widget? decrementIcon, Duration longPressInterval = const Duration(milliseconds: 100), MainAxisAlignment? alignment})
Factory constructor for squared buttons with equal width and height and customizable border radius.
factory

Properties

alignment → MainAxisAlignment?
The alignment of the buttons and quantity display within the widget.
final
backgroundColor → Color?
The background color of the widget.
final
borderColor → Color?
The border color of the buttons.
final
borderRadius → double?
The border radius of the widget's buttons.
final
borderWidth → double
The thickness of the border. Defaults to 1.0.
final
buttonHeight → double?
The height of the increment and decrement buttons.
final
buttonMargin → EdgeInsetsGeometry?
The external margin around each increment and decrement button.
final
buttonPadding → EdgeInsetsGeometry?
The padding inside the increment and decrement buttons.
final
buttonShape → OutlinedBorder?
The shape of the increment and decrement buttons.
final
buttonWidth → double?
The width of the increment and decrement buttons.
final
decrementIcon → Widget?
The icon widget for the decrement button.
final
elevation → double?
The elevation (shadow depth) of the widget.
final
hashCode → int
The hash code for this object.
no setterinherited
height → double?
The height of the entire widget.
final
iconColor → Color?
The color of the widget's icons.
final
incrementIcon → Widget?
The icon widget for the increment button.
final
key → Key?
Controls how one widget replaces another widget in the tree.
finalinherited
longPressInterval → Duration
The interval between repeated increment/decrement actions during a long press.
final
margin → EdgeInsetsGeometry?
The external margin around the widget.
final
maxQuantity → int?
The maximum allowed quantity.
final
minValue → int?
The minimum allowed quantity.
final
onChanged → ValueUpdate?
A callback function that is invoked whenever the quantity changes.
final
quantity → int
The initial quantity to display.
final
quantityTextStyle → TextStyle?
The text style for displaying the quantity.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
splashColor → Color?
The splash color of the buttons when tapped.
final
splashFactory → InteractiveInkFeatureFactory?
The splash factory to define interaction effects.
final
valuePadding → EdgeInsetsGeometry?
The padding inside the quantity display.
final
width → double?
The width of the entire widget.
final

Methods

createElement() → StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
inherited
createState() → State<IncrementDecrementWidget>
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