Stepper
C2CStepper is a custom Flutter widget that provides an interface for inputting numeric or array values through incremental steps. It supports different types of steppers, such as number and array steppers, and offers customizable visual components and behaviors.
Installation
cpub add c2c_stepper
or
flutter pub add c2c_stepper --hosted-url=https://pub.csp.scrum-dev.com
Example
Number Stepper
C2CStepper.numberStepper(
value: 5.0,
step: 1.0,
minNumberStep: 0.0,
maxNumberStep: 10.0,
onChanged: (value) {
// Handle value change
},
// Additional customizations
);
Array Stepper
C2CStepper.arrayStepper(
steppers: ['Option1', 'Option2', 'Option3'],
maxIndexStep: 2,
minIndexStep: 0,
onChanged: (value) {
// Handle value change
},
// Additional customizations
);
Properties
| Property | Description | Type |
|---|---|---|
value | The initial value of the stepper. | T? |
stepperDelegate | A delegate that handles the stepper logic. | C2CStepperDelegate |
valueViewBuilder | Custom widget builder for displaying the stepper's value. | C2CStepperValueBuilder<T>? |
addButtonViewBuilder | Custom widget builder for the "add" button. | C2CStepperAddBuilder<T>? |
minusButtonViewBuilder | Custom widget builder for the "minus" button. | C2CStepperMinusBuilder<T>? |
isExpandedWidget | Expands the widget if set to true. | bool |
onChanged | Callback when a selection is made. | ValueChanged<T?>? |
enabled | Determines if the stepper is enabled. | bool |
valueTextStyle | Style for the value text. | TextStyle? |
valueDisableColor | Color for the value text when the stepper is disabled. | Color? |
descriptionDisableColor | Color for the description text when the stepper is disabled. | Color? |
description | A description that can be either a String or a Widget. | dynamic |
descriptionTextStyle | Style for the description text. | TextStyle? |
helperText | Helper text that can be either a String or a Widget. | dynamic |
error | An error message that can be either a String or a Widget. | dynamic |
showErrorMessage | Shows an error message if true. | bool |
errorTextStyle | Style for the error text. | TextStyle? |
helperTextStyle | Style for the helper text. | TextStyle? |
errorMaxLines | Maximum number of lines for the error text. | int? |
helperMaxLines | Maximum number of lines for the helper text. | int? |
C2CStepperValueBuilder<T>
typedef C2CStepperValueBuilder<T> = Widget Function(BuildContext context, bool enabled, T? value);
- A builder function that creates a custom widget for displaying the stepper's value.
context: The build context.enabled: Whether the stepper is enabled.value: The current value of the stepper.
C2CStepperAddBuilder<T>
typedef C2CStepperAddBuilder<T> = Widget Function(BuildContext context, bool enabled, T? value, VoidCallback onPress);
- A builder function to create a custom widget for the "add" button.
context: The build context.enabled: Whether the stepper is enabled.value: The current value of the stepper.onPress: The callback function to execute when the "add" button is pressed.
C2CStepperMinusBuilder<T>
typedef C2CStepperMinusBuilder<T> = Widget Function(BuildContext context, bool enabled, T? value, VoidCallback onPress);
- A builder function to create a custom widget for the "minus" button.
context: The build context.enabled: Whether the stepper is enabled.value: The current value of the stepper.onPress: The callback function to execute when the "minus" button is pressed.