WheelPicker class
A customizable scrolling wheel interface for selecting items, such as numbers, dates, or any value of your choice.
Key Features:
- Supports both looping and non-looping scrolling behavior.
- Customizable appearance and styling through
WheelPickerStyle
. - Enables tap gestures for intuitive navigation through the wheel.
- Easily integrates with a controller for precise control and synchronization.
- Provides the ability to highlight the selected item with a color shader.
Usage:
WheelPicker
is highly configurable and can be adapted to different use cases by specifying the builder function, initial settings, and style properties. It's a valuable component for creating user-friendly and visually appealing selection interfaces in your Flutter applications.
Example:
WheelPicker(
builder: (context, index) {
// Define how each item in the wheel should be rendered.
return Text('Item $index');
},
itemCount: 10, // Number of items in the wheel.
initialIndex: 2, // Initial selected item.
looping: true, // Enable looping behavior.
selectedIndexColor: Colors.blue, // Color to highlight the selected item.
enableTap: true, // Allow tap gestures for navigation.
onIndexChanged: (index) {
// Handle index changes.
print('Selected index: $index');
},
style: WheelPickerStyle(
// Customize the appearance and behavior.
size: 150,
itemExtent: 50,
// ...
),
)
Simplify the process of creating scrollable selection wheels in Flutter, making it easier to build interactive and engaging user interfaces.
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- WheelPicker
Constructors
- WheelPicker({required Widget builder(BuildContext context, int index), int? itemCount, WheelPickerController? controller, int? initialIndex, bool looping = true, Axis scrollDirection = Axis.vertical, Color? selectedIndexColor, bool enableTap = true, void onIndexChanged(int index)?, WheelPickerStyle style = const WheelPickerStyle(), Key? key})
-
Creates a
WheelPicker
widget with customizable options.const
Properties
- builder → Widget Function(BuildContext context, int index)
-
Callback for creating item widgets based on their index.
final
- controller → WheelPickerController?
-
A controller for retrieving the selected item index, controlling wheel behavior, shifting it, and enabling mounting of additional WheelPickerController controllers for shifting them when looping.
final
- enableTap → bool
-
Whether to enable tap gestures for item selection.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- initialIndex → int?
-
The initially selected item index. Use this property when not using a controller.
final
- itemCount → int?
-
The total number of items. This is used when no controller is provided.
final
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- looping → bool
-
Whether the wheel should support infinite looping, allowing it to loop both forward and backward.
final
- onIndexChanged → (void Function(int index)?)
-
Callback function that is called for when the selected item index changes.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- scrollDirection → Axis
-
Determines how the wheel is oriented and scrolled.
final
- selectedIndexColor → Color?
-
The color used to highlight the selected item(center) using a shader mask.
final
- style → WheelPickerStyle
-
Defines the appearance and behavior style for the
WheelPicker
.final
Methods
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → State< WheelPicker> -
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}) → 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