Skip to content

Instantly share code, notes, and snippets.

@Khanin-devmode
Last active December 12, 2023 14:47
Show Gist options
  • Save Khanin-devmode/c0174f9a623dfc2bc8660dcf85d211d8 to your computer and use it in GitHub Desktop.
Save Khanin-devmode/c0174f9a623dfc2bc8660dcf85d211d8 to your computer and use it in GitHub Desktop.
Widget book example in one file
import 'package:flutter/material.dart';
import 'package:widgetbook/widgetbook.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return Widgetbook.material(directories: [
WidgetbookFolder(
name: 'Atoms',
children: [
WidgetbookComponent(
name: 'Component1',
useCases: [
WidgetbookUseCase(
name: 'Usecase1',
builder: (BuildContext context) {
return Scaffold();
},
),
WidgetbookUseCase(
name: 'Usecase2',
builder: (BuildContext context) {
return Scaffold();
},
),
WidgetbookUseCase(
name: 'Usecase3',
builder: (BuildContext context) {
return Scaffold();
},
),
],
),
WidgetbookComponent(
name: 'Component2',
useCases: [
WidgetbookUseCase(
name: 'Usecase1',
builder: (BuildContext context) {
return Scaffold();
},
),
WidgetbookUseCase(
name: 'Usecase2',
builder: (BuildContext context) {
return Scaffold();
},
),
WidgetbookUseCase(
name: 'Usecase3',
builder: (BuildContext context) {
return Scaffold();
},
),
],
),
],
)
]);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment