Integer Arg

The integer arg renders a text field or slider in the Widgetbook UI where you can dynamically enter an int value for a widget property.

Variants

The integer arg has two style variants, each with a regular and nullable type:

  • Input: A text field for entering integer values.
  • Slider: A slider for selecting integer values within a range.

IntArg (Input)

By default, IntArg uses the input style.

Example

Usage

my_widget.stories.dart
final $Default = _Story(
  args: _Args(
    count: IntArg(5), 
  ),
);

NullableIntArg (Input)

Example

Usage

my_widget.stories.dart
final $Default = _Story(
  args: _Args(
    count: NullableIntArg(null), 
  ),
);

IntArg (Slider)

To use the slider style, pass a SliderIntArgStyle to the style parameter.

Example

Usage

my_widget.stories.dart
final $Default = _Story(
  args: _Args(
    count: IntArg( 
      5, 
      style: const SliderIntArgStyle(min: 0, max: 200, divisions: 20), 
    ), 
  ),
);

Properties

minintrequired

The minimum value of the slider.

maxintrequired

The maximum value of the slider.

divisionsintrequired

The number of discrete divisions on the slider.

NullableIntArg (Slider)

Example

Usage

my_widget.stories.dart
final $Default = _Story(
  args: _Args(
    count: NullableIntArg( 
      null, 
      style: const SliderIntArgStyle(min: 0, max: 200, divisions: 20), 
    ), 
  ),
);