Integer Knob
The integer input knob renders a text field in the Widgetbook UI where you can dynamically enter an int value for a widget property. This is particularly useful for properties that require an integer input, such as shown in a notification badge.
Varients
The integer input knob has two variants:
context.knobs.int.input()
: This variant allows you to enter an integer value via a text field. It does not acceptnull
values.context.knobs.intOrNull.input()
: This variant allows you to enter an integer value via a text field or set the value tonull
. It is useful when the property can be optional.
Properties
Besides the knob's base properties, the integer input knob does not feature any additional properties.
Usage
To use the integer input knob, call the context.knobs.int.input()
method.
@UseCase(type: MyWidget, name: 'Default')
Widget buildUseCase(BuildContext context) {
return MyWidget(
count: context.knobs.int.input(label: 'count', initialValue: 100),
);
}
Usage
To use the nullable integer input knob, call the context.knobs.intOrNull.input()
method.
@UseCase(type: MyWidget, name: 'Default')
Widget buildUseCase(BuildContext context) {
return MyWidget(
count: context.knobs.intOrNull.input(label: 'count'),
);
}
Multi-snapshot Support
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 IntKnobConfig page for more information.