widgetbook_generator 1.0.1-beta.2 widgetbook_generator: ^1.0.1-beta.2 copied to clipboard
A package to automate setup and maintanance of the widgetbook package by using code generation.
import 'package:flutter/material.dart';
import 'package:widgetbook_annotation/widgetbook_annotation.dart';
@WidgetbookTheme.dark()
ThemeData darkTheme() => ThemeData.dark();
@WidgetbookStory(name: 'Default', type: CustomPadding)
Widget customPaddingStory(BuildContext context) {
return Container(
color: Colors.green,
child: CustomPadding(
widget: Text('Test'),
),
);
}
class CustomPadding extends StatelessWidget {
final Widget widget;
const CustomPadding({
Key? key,
required this.widget,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return Padding(
padding: EdgeInsets.all(16),
child: widget,
);
}
}
@WidgetbookApp(name: 'Example App')
class App extends StatelessWidget {
const App({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
theme: darkTheme(),
);
}
}