Skip to content
pubscout

dag

0.1.2, released 2 months ago by finchdart.com

Transpiles .dag files containing text and embedded Dart code into plain .dart source files.

$ flutter pub add dag
Source repository

What it does

Transpiles .dag files—which mix literal output text with embedded Dart code PHP-style—into plain .dart source code. It features whitespace control, parameter definitions, hoisting of imports, and supports compilation via a CLI tool or package:build.

AI-written summary of version 0.1.2, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You want to generate text, HTML, or code using PHP-style template files where the file compiles directly to Dart code.
  • You want compile-time transpilation of text-with-code files rather than runtime template interpretation.

Skip it when

  • You need a standard runtime template engine.
  • Your project cannot use code generation or the provided CLI tools.

Strengths

  • Compiles directly to real Dart code with zero runtime interpretation overhead.
  • Supports both a CLI tool and a package:build Builder via build_runner.
  • Provides helpful DagError traceback reporting exact .dag file line numbers.

Weaknesses

  • A literal '?>' inside a tag's Dart code will close the tag early.
  • Requires a build pipeline or CLI step during development.

Setup

Kind
Pure Dart
Effort
Low
Code generation
Yes (build_runner)
Direct dependencies
4

Add the package via pub add dag and either use the CLI tool or integrate with build_runner.

import 'package:dag/dag.dart';

final dartSource = transpile(dagSource);

Alternatives

Packages that do the same job and could replace dag.

  • source_gen

    Source code generation builders and utilities for the Dart build system.

  • protobuf

    Provides runtime support for Dart protocol buffer messages generated by protoc_plugin.

  • embed

    Generates Dart code that embeds arbitrary file contents as literals.

Works with

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