Story<TWidget extends Widget, TArgs extends StoryArgs<TWidget>> class abstract

Annotations

Constructors

Story({String? name, String? designLink, SetupBuilder<TWidget, TArgs> setup = defaultSetup, List<Mode>? modes, required TArgs args, required StoryWidgetBuilder<TWidget, TArgs> builder, List<Scenario<TWidget, TArgs>> scenarios = const []})

Properties

$generatedName String
latefinal
args → TArgs
final
builder StoryWidgetBuilder<TWidget, TArgs>
Defines how the TWidget is built using the provided TArgs.
final
component Component<Widget, StoryArgs<Widget>>
A late back-reference to the component this story belongs to. It is initialized in the Component constructor.
latefinal
final
hashCode int
The hash code for this object.
no setterinherited
modes List<Mode>?
These Modes are only applied to Scenarios in this Story using the Scenario.mergeModes function to combine them with Scenario.modes. They are not applied to the Story itself.
final
name String
no setter
path String
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
scenarios List<Scenario<TWidget, TArgs>>
final
setup SetupBuilder<TWidget, TArgs>
final

Methods

allScenarios(Config config) List<Scenario<TWidget, TArgs>>
A list of all scenarios for this story, assembled from the local ones defined in scenarios and the ones generated from the ScenarioDefinitions in the Config, according to each definition's ScenarioStrategy.
buildWithConfig(BuildContext context, Config config, {TArgs? args, List<Mode>? modes}) Widget
Builds the story widget wrapped with addons from the provided config. Optionally, args and modes can be provided to override the story's default args and merge modes into the addons.
mergeModesIntoAddons(List<Mode>? modes, List<Addon>? addons) List<Addon>
Merges modes into addons. For example if addons are TextScaleAddon(1), ThemeAddon('dark') and modes are TextScaleMode(3) the result should be TextScaleAddon(3), ThemeAddon('dark').
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

defaultSetup(BuildContext context, Widget widget, StoryArgs args) Widget
By default, Widgetbook forces a rebuild when args change as otherwise StatefulWidgets might not reflect the latest arg values. However, if a story has internal state that should be preserved across arg changes, this can be achieved by overriding the setup function and returning the widget unchanged.