dart_builder 0.0.1-alpha.1 copy "dart_builder: ^0.0.1-alpha.1" to clipboard
dart_builder: ^0.0.1-alpha.1 copied to clipboard

outdatedDart 1 only

A fluent API for creating Dart code.

Dart Builder #

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 ClassDefinition('Foo')
]);

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

Creating a class #

new ClassDefinition('Foo', fields: [
  new FieldDefinition('bar')
], methods: [
  new MethodDefinition('baz')
]);

See definition_test.dart for more examples.

0
likes
0
pub points
5%
popularity

Publisher

unverified uploader

A fluent API for creating Dart code.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

dart_style, mustache

More

Packages that depend on dart_builder