Skip to content
pubscout

mason

0.1.3, released 2 months ago by brickhub.dev

Dart template generator for quick file creation

$ flutter pub add mason
Source repository

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.

  • pubspec_extract

    Extracts Dart pubspec.yaml file and generates pubspec.dart at build time

  • winmd

    Inspect and generate Windows Metadata (.winmd) files based on ECMA-335.

  • license_generator

    A Dart tool to generate a license file containing all third-party library licenses.

Works with

Packages commonly used together with mason: ones it builds on, ones built on it, and its own family.