mason
0.1.3, released 2 months ago by brickhub.dev
Dart template generator for quick file creation
What it does
Mason provides a core generator that can be used to build custom code generation tools. It loads bricks from local or Git sources and renders templates with variables. The generated files are written to a target directory.
AI-written summary of version 0.1.3, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need to generate boilerplate files consistently across a team
- You want to create custom generators for your own project structure
- You are already using mason_cli and want to extend it with custom bricks
Skip it when
- You need runtime UI generation or dynamic widget creation
- You are building a library that requires runtime code execution
Strengths
- Fast, consistent file generation
- Supports Git bricks and local bricks
- Hook system for pre/post generation logic
Weaknesses
- Only for file generation, not runtime code
- Requires manual setup of bricks
- Limited to Dart/Flutter projects
Setup
- Kind
- Pure Dart
- Effort
- Low
- Code generation
- Yes (build_runner)
- Direct dependencies
- 14
Add mason to pubspec, import mason, create a Brick, call MasonGenerator.fromBrick, and generate to a DirectoryGeneratorTarget
import 'dart:io';
import 'package:mason/mason.dart';
Future<void> main() async {
final brick = Brick.git(
const GitPath(
'https://github.com/felangel/mason',
path: 'bricks/greeting',
),
);
final generator = await MasonGenerator.fromBrick(brick);
final target = DirectoryGeneratorTarget(Directory.current);
await generator.generate(target, vars: <String, dynamic>{'name': 'Dash'});
}
Alternatives
Packages that do the same job and could replace mason.
- protobuf
Provides runtime support for Dart protocol buffer messages generated by protoc_plugin.
84Compare - pubspec_extract
Extracts Dart pubspec.yaml file and generates pubspec.dart at build time
75Compare - winmd
Inspect and generate Windows Metadata (.winmd) files based on ECMA-335.
70Compare - license_generator
A Dart tool to generate a license file containing all third-party library licenses.
55Compare
Works with
Packages commonly used together with mason: ones it builds on, ones built on it, and its own family.
- archivemason depends on itEncodes and decodes archive and compression formats such as zip, tar, gzip, and zlib.
- yamlmason depends on itA Dart library for parsing YAML documents into Dart data structures.
- cryptomason depends on itProvides SHA, MD5, and HMAC hashing functions for Dart.
- pub_semvermason depends on itVersions and version constraints implementing pub's versioning policy.
- poolmason depends on itManage a finite pool of resources to control concurrent operations.
- json_annotationmason depends on itProvides annotations for json_serializable to generate JSON (de)serialization code.
- convertmason depends on itEncoders and decoders for converting between different data representations.
- mustache_templatemason depends on itA Dart library that parses and renders Mustache templates.