sandboxed_generator 0.1.5+3
sandboxed_generator: ^0.1.5+3 copied to clipboard
Code generator for Sandboxed components. Automatically creates boilerplate for registering and rendering UI elements in isolation.
⚙️ Sandboxed Generator #
sandboxed_generator is the code generation package for Sandboxed,
a Flutter tool for building, testing, and documenting UI components in isolation.
This package generates the component and story registry used by the sandboxed viewer.
📦 Installation #
Add sandboxed_generator and build_runner to your pubspec.yaml:
dev_dependencies:
build_runner: any
sandboxed_generator:
Replace
{PATH_TO_REPO}with the path to your local clone.
🚀 What It Does #
- Scans for all
MetaandStorydeclarations - Automatically generates a full component registry
- Supports
.mdxdocumentation attachment - Merges with optional manual config
- Fully hot-reload compatible after initial generation
Note
The generator searches for Meta and Story in the current package and all transitive dependencies.
This allows modular story definitions across packages in a monorepo setup.
Usage #
- Define your stories:
Meta get meta => Meta<MyWidget>(name: 'My Widget');
Story get $Primary => Story(
builder: (context, params) => MyWidget(),
);
- Run the generator:
flutter pub run build_runner build
- The generated registry will be picked placed at
lib/components.g.dartfiles. You can pass it toSandboxed.
import 'package:flutter/material.dart';
import 'package:sandboxed/sandboxed.dart';
import 'package:{your_package}/components.g.dart';
void main() {
runApp(
Sandboxed(
title: Text("Brand Name"),
components: components,
),
);
}
🛠 Configuration #
You can optionally configure the generator with a build.yaml file to change:
- Output location (WIP)
- Entry point scanning behavior (WIP)
- Filtering rules (WIP)
🔗 Related Packages #
sandboxed— Viewer Appsandboxed_core— Meta / Story primitivessandboxed_ui_kit— Viewer UI components
License #
This project is licensed under the Elastic License 2.0 - see the LICENSE file for details.