⚙️ 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.
Libraries
- aggregator
- builder
- builders/story_parameter_builder
- config/aggregator_config
- docs_cleaner
- exception/unsupported_parameters
- expression/raw
- extension/dart_type_extension
- extension/escape_identifier_x
- gatherer
- parsers/library_parser
- parsers/meta_parser
- parsers/story_parser
- types/type_checker
- types/type_checkers
- types/type_handlers
- visitors/story_copy_with_visitor