dart_builder 0.1.1 copy "dart_builder: ^0.1.1" to clipboard
dart_builder: ^0.1.1 copied to clipboard

Dart 1 only

A fluent API for creating Dart code.

Dart Builder #

Build Status

Getting Started #

The most common scenario is creating a new generated file in a transformer or build step. Dart builder provides the SourceFile class to output either a library or a part file (of another library):

var file = new SourceFile.library('bar');
file.toSource(); // Outputs "library bar;\n"

It's possible to import other libraries or files:

new SourceFile.library('bar', imports: [
  new ImportDirective(Uri.parse('package:foo/foo.dart'))
]);

And include other dart constructs, like classes or methods:

new SourceFile.library('bar', topLevelElements: [
  new ClassRef('Foo')
]);

NOTE: By default, SourceFile.toSource() applies the dart formatter.

Creating a class #

new ClassRef('Foo', fields: [
  new FieldRef('bar')
], methods: [
  new MethodRef('baz')
]);

See tests for more examples.

0
likes
15
pub points
5%
popularity

Publisher

unverified uploader

A fluent API for creating Dart code.

Repository (GitHub)
View/report issues

License

Apache-2.0 (license)

Dependencies

dart_style, mustache, quiver

More

Packages that depend on dart_builder