Widgetbook: A Flutter Package for Widget Management and Testing

Published on by Flutter News Hub

Widgetbook: A Flutter Package for Widget Management and Testing

Widgetbook is an open-source Flutter package inspired by Storybook.js that simplifies the cataloging, testing, and sharing of widgets. It empowers developers to create comprehensive documentation and streamline the development process.

Features

  • Seamless integration with Flutter
  • Feature-rich testing options for multiple devices, themes, and more
  • Customizable settings for tailored experiences
  • Excellent maintenance and support from a German startup
  • Vibrant Discord community for support

Benefits

  • Centralized widget catalog prevents duplication
  • Isolated development environment for focused work
  • Knobs provide customizable interactions
  • Hot reload ensures quick bug fixing

Widgetbook Cloud

Widgetbook Cloud enhances collaboration by:

  • Facilitating widget sharing with stakeholders
  • Simplifying review processes
  • Integrating with Figma for seamless design-to-code flow

Documentation

Visit docs.widgetbook.io for detailed documentation and examples on:

  • Installing and configuring Widgetbook
  • Creating and testing widgets
  • Customizing settings
  • Using advanced features like knobs and interactions

Code Examples

// Install Widgetbook via pub:
//
// dependencies:
//   widgetbook: ^2.0.0+1

// Create a widget for testing:
//
import 'package:widgetbook/widgetbook.dart';
import 'package:flutter/material.dart';

class MyWidget extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Text('Hello, Widgetbook!');
  }
}

// Add a widget to Widgetbook:
//
Widgetbook.instance.addCatalog(
  Catalog(
    name: 'My Catalog',
    widgets: [
      WidgetbookSimplePage(
        name: 'My Widget',
        widget: MyWidget(),
      ),
    ],
  ),
);

// Run Widgetbook:
//
void main() => runApp(WidgetbookApp());
Flutter News Hub