SpinnerWheel<T> class
A customizable spinning wheel widget.
The SpinnerWheel allows you to create an interactive wheel with multiple WheelSegments. It supports custom backgrounds, center widgets, indicators, and smooth spin animations controlled by a SpinnerController.
T is the type of the segments' WheelSegment.value; it is usually
inferred from segments.
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- SpinnerWheel
Constructors
-
SpinnerWheel({Key? key, required SpinnerController controller, required List<
WheelSegment< segments, required void onComplete(WheelSegment<T> >T> segment, int index), VoidCallback? onSpinStart, void onSegmentPass(int index)?, Duration spinDuration = const Duration(seconds: 5), Curve spinCurve = Curves.decelerate, int minSpins = 5, int maxSpins = 9, bool tapToSpin = false, bool swipeToSpin = false, IndicatorPosition indicatorPosition = IndicatorPosition.top, bool indicatorBounce = false, SliceSizing sliceSizing = SliceSizing.equal, SliceStyle sliceStyle = SliceStyle.gradient, Color? sliceBorderColor, double sliceBorderWidth = 0, bool highlightWinner = false, Color highlightColor = Colors.white, Widget? imagePlaceholder, Widget? imageErrorWidget, void onImageError(WheelSegment<T> segment, Object error)?, String? semanticsLabel, Color? wheelColor, WheelFrame? frame, double? wheelInset, Color? indicatorColor, Widget? centerChild, Widget? indicator, double? imageHeight, double? imageWidth, WheelLabelStyle? labelStyle, Widget? background, bool shouldDrawBackground = true, EdgeInsets slicePadding = EdgeInsets.zero}) -
Creates a SpinnerWheel.
const
Properties
- background → Widget?
-
A custom background widget displayed behind the segments, in place of
the default frame.
final
- centerChild → Widget?
-
A custom widget to display at the center of the wheel (e.g., a button or logo).
final
- controller → SpinnerController
-
Controls the spin animation of the wheel.
final
- drawsFrame → bool
-
Whether the painted frame is shown (no custom background, and
shouldDrawBackground is on).
no setter
- effectiveFrame → WheelFrame
-
The frame actually used: frame, or a classic frame in wheelColor.
no setter
- effectiveWheelInset → double
-
The inset actually used: wheelInset, or what the frame prefers.
no setter
- frame → WheelFrame?
-
The frame drawn around the wheel. Frames are painted, so they stay
sharp at any size.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- highlightColor → Color
-
Outline color of the highlighted winning slice.
final
- highlightWinner → bool
-
Whether to highlight the winning slice (and dim the others) after a
spin. The highlight clears when the next spin starts.
final
- imageErrorWidget → Widget?
-
Shown in place of a segment's image if it fails to load.
final
- imageHeight → double?
-
The height of images displayed within segments.
final
- imagePlaceholder → Widget?
-
Shown in place of a segment's image while it loads.
final
- imageWidth → double?
-
The width of images displayed within segments.
final
- indicator → Widget?
-
A custom widget for the wheel's indicator (the "pointer").
final
- indicatorBounce → bool
-
Whether the indicator flicks each time a segment passes under it.
final
- indicatorColor → Color?
-
The color of the default indicator. Defaults to the frame's
WheelFrame.indicatorColor, or red.
final
- indicatorPosition → IndicatorPosition
-
Which side of the wheel the indicator sits on.
final
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- labelStyle → WheelLabelStyle?
-
Configuration for the label style (text style, angle, etc.).
final
- maxSpins → int
-
The most whole turns a spin makes before slowing to a stop.
final
- minSpins → int
-
The fewest whole turns a spin makes before slowing to a stop.
final
-
onComplete
→ void Function(WheelSegment<
T> segment, int index) -
Callback called when the wheel stops spinning.
Returns the selected WheelSegment and its index.
final
-
onImageError
→ void Function(WheelSegment<
T> segment, Object error)? -
Called when a segment's image fails to load.
final
- onSegmentPass → void Function(int index)?
-
Called every time a new segment passes under the indicator, while
spinning or dragging. Handy for tick sounds or haptic feedback.
final
- onSpinStart → VoidCallback?
-
Called when a spin starts, whether from the controller, a tap or a
swipe.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
segments
→ List<
WheelSegment< T> > -
The list of segments (slices) to display on the wheel.
final
- semanticsLabel → String?
-
A description of the wheel for screen readers. Defaults to
"Spinning wheel".
final
- shouldDrawBackground → bool
-
Whether to draw the default frame or the provided background.
final
- sliceBorderColor → Color?
-
Color of the lines between slices and around the wheel.
final
- sliceBorderWidth → double
-
Width of the lines between slices and around the wheel. 0 draws none.
final
- slicePadding → EdgeInsets
-
Padding within segments for images and text.
final
- sliceSizing → SliceSizing
-
How the sizes of the slices are decided.
final
- sliceStyle → SliceStyle
-
How each slice is filled.
final
- spinCurve → Curve
-
The easing of a spin started from the controller or a tap.
final
- spinDuration → Duration
-
How long a spin takes.
final
- swipeToSpin → bool
-
Whether the wheel can be dragged around and flung to spin it.
final
- tapToSpin → bool
-
Whether tapping the center of the wheel starts a spin.
final
- wheelColor → Color?
-
The rim color of the classic frame. A shortcut for
frame: WheelFrame.classic(rimColor: ...); ignored when frame is set.final - wheelInset → double?
-
Gap between the wheel's outer edge and the segments, as a fraction of
the wheel size (0.0 to 0.5). The frame fills this gap.
final
Methods
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → State< SpinnerWheel< T> > -
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