Boolean Arg

The boolean arg renders a toggle switch in the Widgetbook UI where you can dynamically toggle a bool value for a widget property.

Variants

The boolean arg has two variants:

  • BoolArg: Allows you to toggle a bool value. Does not accept null values.
  • NullableBoolArg: Allows you to toggle a bool value or set it to null. Useful when the property is optional.

BoolArg

Example

Usage

my_widget.stories.dart
final $Default = _Story(
  args: _Args(
    isEnabled: BoolArg(true), 
  ),
);

NullableBoolArg

Example

Usage

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