How Dashbook works: Stories, Chapters, and Decorators
mainDashbook organizes UI components using a hierarchical structure:
- Stories: A collection of related widgets (e.g., all variations of a
Textwidget). - Chapters: Specific variants or states of a story (e.g., a
Textwidget with a specific alignment). - Decorators: Functions used to apply a common layout or styling to all chapters within a story (e.g.,
CenterDecorator()to center all widgets).
You build a Dashbook instance by chaining these methods and finally passing the instance to runApp().
final dashbook = Dashbook();
dashbook
.storiesOf('Text')
.decorator(CenterDecorator())
.add('default', (ctx) {
return Text(ctx.textProperty("text", "Example"));
});
runApp(dashbook);