Skip to content
pubscout

widgetbook_annotation

3.11.0, released 9 months ago by widgetbook.io

Annotations for widgetbook_generator to build Flutter widgets in isolation.

WASM-ready
$ flutter pub add widgetbook_annotation
Source repository

What it does

Provides annotations used alongside widgetbook_generator to define use-cases and configure components for Widgetbook. It is part of the tooling used for developing UI components in isolation.

AI-written summary of version 3.11.0, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You are setting up Widgetbook for component development in Flutter
  • You use widgetbook_generator to automatically generate your Widgetbook app structure

Skip it when

  • You are not using Widgetbook or code generation for your UI components
  • You are looking for state management or runtime UI packages

Strengths

  • Simplifies Widgetbook setup with declarative annotations
  • Integrates seamlessly with build_runner and widgetbook_generator

Weaknesses

  • Requires build_runner and code generation steps
  • Provides only annotations; requires the companion generator and core packages to function

Setup

Kind
Pure Dart
Effort
Low
Code generation
No
Direct dependencies
1

Add to pubspec.yaml alongside build_runner and widgetbook_generator.

import 'package:widgetbook_annotation/widgetbook_annotation.dart';

@UseCase(name: 'Default', type: MyWidget)
Widget buildMyWidgetUseCase(BuildContext context) {
  return MyWidget();
}

Alternatives

Packages that do the same job and could replace widgetbook_annotation.

Works with

Packages commonly used together with widgetbook_annotation: ones it builds on, ones built on it, and its own family.