The integer slider knob renders a slider in the Widgetbook UI where you can dynamically enter an integer value for a widget property. This is particularly useful for properties that require an integer input, such as shown in a notification badge.
The double slider knob has two variants:
context.knobs.int.slider(): This variant allows you to enter an integer value via a slider. It does not acceptnullvalues.context.knobs.intOrNull.slider(): This variant allows you to enter an integer value via a slider or set the value tonull. It is useful when the property can be optional.
Widgetbook also offers support for input-based integer knobs which are documented on the Integer Input Knob page.
In addition to the knob's base properties, the integer slider knob includes the following properties:
The minimum value the slider can select. This defines the start of the slider's range.
Defaults to 0.
The maximum value the slider can select. This defines the end of the slider's range.
Defaults to 20.
Sets how many evenly spaced discrete values are available between min and max.
When set, the slider snaps to these fixed intervals. For example, with min: 0, max: 10, and divisions: 5, the selectable values will be: 0, 2, 4, 6, 8, 10.
Defaults to null, which allows continuous values.
To use the integer input knob, call the context.knobs.int.slider() method.
@UseCase(type: MyWidget, name: 'Default')
Widget buildUseCase(BuildContext context) {
return MyWidget(
count: context.knobs.int.slider(
label: 'count',
min: 0,
max: 100,
divisions: 20,
initialValue: 100,
),
);
}To use the nullable double input knob, call the context.knobs.doubleOrNull.input() method.
@UseCase(type: MyWidget, name: 'Default')
Widget buildUseCase(BuildContext context) {
return MyWidget(
count: context.knobs.intOrNull.slider(
label: 'count',
min: 0,
max: 100,
divisions: 20,
),
);
}Multi-snapshot support for Widgetbook Cloud allows you to generate multiple screenshots of a single use case with varying values using KnobsConfigs and AddonsConfigs.
Please refer to the Multi-snapshot Support page for more information about IntegerKnobConfig.

