A fluent API for generating valid Dart source code

Overview

Pub package Build Status Gitter chat

A fluent, builder-based library for generating valid Dart code.

Usage

code_builder has a narrow and user-friendly API.

See the example and test folders for additional examples.

For example creating a class with a method:

import 'package:code_builder/code_builder.dart';
import 'package:dart_style/dart_style.dart';

void main() {
  final animal = Class((b) => b
    ..name = 'Animal'
    ..extend = refer('Organism')
    ..methods.add(Method.returnsVoid((b) => b
      ..name = 'eat'
      ..body = const Code("print('Yum');"))));
  final emitter = DartEmitter();
  print(DartFormatter().format('${animal.accept(emitter)}'));
}

Outputs:

class Animal extends Organism {
  void eat() => print('Yum!');
}

Have a complicated set of dependencies for your generated code? code_builder supports automatic scoping of your ASTs to automatically use prefixes to avoid symbol conflicts:

import 'package:code_builder/code_builder.dart';
import 'package:dart_style/dart_style.dart';

void main() {
  final library = Library((b) => b.body.addAll([
        Method((b) => b
          ..body = const Code('')
          ..name = 'doThing'
          ..returns = refer('Thing', 'package:a/a.dart')),
        Method((b) => b
          ..body = const Code('')
          ..name = 'doOther'
          ..returns = refer('Other', 'package:b/b.dart')),
      ]));
  final emitter = DartEmitter.scoped();
  print(DartFormatter().format('${library.accept(emitter)}'));
}

Outputs:

import 'package:a/a.dart' as _i1;
import 'package:b/b.dart' as _i2;

_i1.Thing doThing() {}
_i2.Other doOther() {}

Contributing

If a feature is missing (the Dart language is always evolving) or you'd like an easier or better way to do something, consider opening a pull request. You can always file an issue, but generally speaking feature requests will be on a best-effort basis.

NOTE: Due to the evolving Dart SDK the local dartfmt must be used to format this repository. You can run it simply from the command-line:

$ pub run dart_style:format -w .

Updating generated (.g.dart) files

NOTE: There is currently a limitation in build_runner that requires a workaround for developing this package. We expect this to be unnecessary in the future.

Use build_runner:

$ pub global activate build_runner
$ mv build.disabled.yaml build.yaml
$ pub global run build_runner build --delete-conflicting-outputs
$ mv build.yaml build.disabled.yaml
Comments
  • Unable to resolve dependency with Angular2

    Unable to resolve dependency with Angular2

    Resolving dependencies... Package dart_style has no versions that match >=0.2.10 <2.0.0 derived from:

    • angular2 3.1.0 depends on version >=0.1.8 <2.0.0
    • code_builder 1.0.3 depends on version >=0.2.10 <2.0.0
    resolution: invalid 
    opened by mkhan-akhan 14
  • Intent to release: 3.0.0

    Intent to release: 3.0.0

    Before we have lots more usage, we might want to try and ship 3.0.0.

    Specifically, with the following breaking changes:

    • Remove automatic dartfmt with use of equalsDart.
    • Remove all uses of Annotation.
    • Change {Method|Constructor}.lambda to default to null (infer).
    • Remove all uses of File.

    Any other ideas/thoughts? /cc @kevmoo @natebosch @alorenzen @thosakwe

    opened by matanlurey 11
  • FieldBuilders now works top-level

    FieldBuilders now works top-level

    Until now, you'd get an error when trying to use a FieldBuilder at the top-level, because it extends TopLevelMixin. However, the FieldBuilder class is already capable of building top-level, so there is no need to throw the error.

    The commit is small. :)

    cla: yes 
    opened by thosakwe 11
  • Builders should provide accessors to their fields

    Builders should provide accessors to their fields

    For example, imagine I was to construct a factory that forwards its parameters to a constructor:

    class Foo {
      factory Foo(A a, B b, C c) {
        return new Foo._(a, b, c);
      }
    
      Foo._(A a, B b, C c);
    }
    

    To generate factory Foo(A a, B b, C c) I will have a List<ParameterBuilder>. To forward the parameters to Foo._, I want to be able to convert List<ParameterBuilder> to a List<ExpressionBuilder> args and pass that to myType.newInstance(args).

    Example:

    List<ExpressionBuilder> forwardParamsToArgs(List<ParameterBuilder> params) {
      return params.map<ExpressionBuilder>((p) => reference(p.name)).toList();
    }
    

    Unfortunately p.name does not exist.

    opened by yjbanov 10
  • Add support for trailing commas in Emitter

    Add support for trailing commas in Emitter

    Fixes https://github.com/dart-lang/code_builder/issues/365

    This adds trailing commas in various places according to the following rules:

    • in a collection literal if there are more than one element
    • in an argument list if there are more than one argument (positional or named)
    • in a constructor parameter list, method parameter list, or function type parameter list, if there are more than one parameter (positional, optional, or named)

    The last one was certainly the most complex, because of the optional/named delimiters ([]/{}).

    • A parameter list with one positional or one optional or one named parameter does not get a trailing comma.
    • A parameter list with multiple positional parameters and no optional or named parameters gets a trailing comma.
    • A parameter list with at least one optional parameter or at least one named parameter, and at least two parameters in total, gets a trailing comma before the closing delimiter (] or }).
    opened by srawlins 9
  • Add annotations to libraries

    Add annotations to libraries

    Adds the ability to annotate a Library generated by code_builder. This is to support scenarios like JavaScript interop using package:js where the library itself needs to be annotated with @JS().

    cla: yes 
    opened by donny-dont 9
  • Migrate away from built_value

    Migrate away from built_value

    I'm not sure if it would be breaking...

    I think we should hand code the builders. It's a little annoying but this package is used in a lot of infrastructure around codegen and the dep is pretty limiting.

    @matanlurey - if you don't have a problem with this I can try to take a stab at a PR sometime in the next couple weeks.

    chore 
    opened by natebosch 9
  • How can I call a named constructor with arguments when defining Class fields?

    How can I call a named constructor with arguments when defining Class fields?

    I want to generate dart classes from a YAML schema. I define my fields as follows:

      List<Field> fields = messageYaml['fields'].map<Field>((field) {
        return Field((b) => b
          ..assignment = Reference('CustomVar', 'package:sandbox/types/custom_var.dart').newInstance([]).code
          ..name = field['name']
          ..modifier = FieldModifier.final$
          ..type = refer('CustomVar', 'package:sandbox/types/custom_var.dart'));
      }).toList();
    

    This works fine calling the default constructor. What I cannot figure out is how I call my named constructor or how to even pass my YAML to this constructor..

     CustomVar.fromYaml(YamlMap yaml);
     or...
    CustomVar(YamlMap yaml);
    

    I know this is probably not the best location to ask these questions, but this is not something a lot of people have knowledge about so the issue tracker seemed like the best place to ask :)

    opened by anthonyorona 8
  • Add support for nullsafety

    Add support for nullsafety

    I am upgrading my package (Kiwi) vanlooverenkoen/kiwi#51

    But it seems that code_builder is not yet migrated to support nullsafety. Is there a timeline on when this could be added?

    chore feature 
    opened by vanlooverenkoen 8
  • Ignore lint about private import prefixes

    Ignore lint about private import prefixes

    In generated code is is more important to avoid potential name conflicts, even unlikely ones, than to satisfy style lints since the code is rarely seen. Ignore no_leading_underscores_for_library_prefixes since this lint is in the recommended set in package:lints.

    opened by natebosch 7
  • Make `FunctionType` implement `TypeReference`

    Make `FunctionType` implement `TypeReference`

    Fixes #174

    • Add a test which fails before this change and passes after
    • Add tests for nested function types since that was untested previously
    • Make FuctionType implement TypeReference, add missing fields returning null and rebuild the built_value file.
    • Return this from the type getter.
    cla: yes 
    opened by natebosch 7
  • reduce the use of trailing commas; add blank lines between groups of fields

    reduce the use of trailing commas; add blank lines between groups of fields

    • reduce the use of trailing commas
    • add blank lines between groups of fields
    • rev the minor version of the package (I realized I added new API in the previous PRs)
    • rev to a non-dev version in prep for publishing

    The two whitespace changes aren't critical but they do make the (post-dartfmt) code I'm generating look better. That's dialing back the use of trailing commas for situations where you likely don't need them, and adding blank lines between different types of field groups (static fields and then instance fields).

    opened by devoncarew 4
  • switch the orderDirectives and useNullSafetySyntax defaults for DartEmitter?

    switch the orderDirectives and useNullSafetySyntax defaults for DartEmitter?

    We may want to switch the orderDirectives and useNullSafetySyntax defaults for DartEmitter; they both currently default to false.

    https://github.com/dart-lang/code_builder/blob/master/lib/src/emitter.dart#L78

    opened by devoncarew 0
  • Named Required Parameters are expected to be passed as optionalParameters

    Named Required Parameters are expected to be passed as optionalParameters

    Named Required Parameters are expected to be passed as optionalParameters

    I had initially written my code to pass required named parameters into the requiredParameters array, that appears to be wrong. It generates this:

    // generates "fib(required int i)" // which is invalid dart.
          Method(
            (b) => b
              ..name = 'fib'
              ..requiredParameters.add(
                Parameter(
                  (b) => b
                    ..name = 'i'
                    ..named = true
                    ..required = true
                    ..type = refer('int').type,
                ),
              ),
          );
    

    There is even a test for this. 🤣 https://github.com/dart-lang/code_builder/blob/master/test/specs/method_test.dart#L496

    The meta issue is that the split between "requiredParameters" and "optionalParameters" doesn't make sense (and isn't documented): https://pub.dev/documentation/code_builder/latest/code_builder/MethodBuilder-class.html (There is no mention of what type of Parameters should end up in one vs the other.)

    opened by eseidel 1
  • emitter generates relative import URLs with backslashes on Windows

    emitter generates relative import URLs with backslashes on Windows

    I don't have a repro for this; this comes from https://github.com/dart-lang/mockito/issues/591 where @adbonnin has a repro.

    Backslashes should not be used in relative import URLs.

    The line of code in question is probably https://github.com/dart-lang/code_builder/blob/master/lib/src/emitter.dart#L336

    problem: bug 
    opened by srawlins 0
  • Would like a (typeless) parameter shorthand.

    Would like a (typeless) parameter shorthand.

    AFAICT, the shortest way to add (foo) to your parameter list is Parameter((b) => b..name = 'foo', feels like there could be something shorter? Maybe there is an I just didn't find it in the code?

    opened by eseidel 2
  • Does code_builder support a notion of target language version?

    Does code_builder support a notion of target language version?

    Or is it completely up to the user to make sure to only use the supported constructs?

    Sometimes (the particular case I'm having at hand is required named arguments) it's possible to handle unsupported constructs gracefully, so for example if a required named argument were requested via builder, the library can generate an actual required arg if version >=2.12 is requested, and just drop the required otherwise.

    opened by yanok 0
Releases(v3.1.3)
  • v3.1.1(Jun 26, 2018)

  • v3.1.0(Jun 1, 2018)

    3.1.0

    • Added Expression.asA for creating explicit casts:
    void main() {
      test('should emit an explicit cast', () {
        expect(
          refer('foo').asA(refer('String')),
          equalsDart('foo as String'),
        );
      });
    }
    
    Source code(tar.gz)
    Source code(zip)
  • v3.0.3(Feb 10, 2018)

    • Fix a bug that caused all downstream users of code_builder to crash due to build_runner trying to import our private builder (in tool/). Sorry for the inconvenience.
    Source code(tar.gz)
    Source code(zip)
  • v3.0.2(Feb 10, 2018)

  • v3.0.1(Jan 30, 2018)

  • v3.0.0(Jan 9, 2018)

  • v3.0.0-alpha(Dec 22, 2017)

    3.0.0-alpha

    • Using equalsDart no longer formats automatically with dartfmt.

    • Removed deprecated Annotation and File classes.

    • Method.lambda is inferred based on Method.body where possible and now defaults to null.

    Source code(tar.gz)
    Source code(zip)
  • v2.4.0(Dec 11, 2017)

  • v2.3.0(Nov 27, 2017)

    • Using equalsDart and expecting dartfmt by default is deprecated. This requires this package to have a direct dependency on specific versions of dart_style (and transitively analyzer), which is problematic just for testing infrastructure. To future proof, we've exposed the EqualsDart class with a format override:
    // Copyright (c) 2017, the Dart project authors.  Please see the AUTHORS file
    // for details. All rights reserved. Use of this source code is governed by a
    // BSD-style license that can be found in the LICENSE file.
    
    import 'package:code_builder/code_builder.dart';
    import 'package:dart_style/dart_style.dart';
    
    final DartFormatter _dartfmt = new DartFormatter();
    String _format(String source) {
      try {
        return _dartfmt.format(source);
      } on FormatException catch (_) {
        return _dartfmt.formatStatement(source);
      }
    }
    
    /// Should be invoked in `main()` of every test in `test/**_test.dart`.
    void useDartfmt() => EqualsDart.format = _format;
    
    • Added Expression.isA and Expression.isNotA:
    void main() {
      test('should emit an is check', () {
        expect(
          refer('foo').isA(refer('String')),
          equalsDart('foo is String'),
        );
      });
    }
    
    • Deprecated Annotation. It is now legal to simply pass any Expression as a metadata annotation to Class, Method, Field, and Parameter. In 3.0.0, the Annotation class will be completely removed:
    void main() {
      test('should create a class with a annotated constructor', () {
        expect(
          new Class((b) => b
            ..name = 'Foo'
            ..constructors.add(
              new Constructor((b) => b..annotations.add(refer('deprecated'))))),
          equalsDart(r'''
            class Foo {
              @deprecated
              Foo();
            }
          '''),
        );
      });
    }
    
    • Added inference support for Method.lambda and Constructor.lambda. If not explicitly provided and the body of the function originated from an Expression then lambda is inferred to be true. This is not a breaking change yet, as it requires an explicit null value. In 3.0.0 this will be the default:
    void main() {
      final animal = new Class((b) => b
        ..name = 'Animal'
        ..extend = refer('Organism')
        ..methods.add(new Method.returnsVoid((b) => b
          ..name = 'eat'
          // In 3.0.0, this may be omitted and still is inferred.
          ..lambda = null
          ..body = refer('print').call([literalString('Yum!')]).code)));
      final emitter = new DartEmitter();
      print(new DartFormatter().format('${animal.accept(emitter)}'));
    }
    
    • Added nullSafeProperty to Expression to access properties with ?.
    • Added conditional to Expression to use the ternary operator ? :
    • Methods taking positionalArguments accept Iterable<Expression>
    • BUG FIX: Parameters can take a FunctionType as a type. Reference.type now returns a Reference. Note that this change is technically breaking but should not impacts most clients.
    Source code(tar.gz)
    Source code(zip)
  • v2.2.0(Nov 22, 2017)

    • Imports are prefixed with _i1 rather than _1 which satisfies the lint lowercase_with_underscores. While not a strictly breaking change you may have to fix/regenerate golden file-like tests. We added documentation that the specific prefix is not considered stable.

    • Added Expression.index for accessing the [] operator:

    void main() {
      test('should emit an index operator', () {
        expect(
          refer('bar').index(literalTrue).assignVar('foo').statement,
          equalsDart('var foo = bar[true];'),
        );
    }  );
    
      test('should emit an index operator set', () {
        expect(
          refer('bar')
            .index(literalTrue)
            .assign(literalFalse)
            .assignVar('foo')
            .statement,
          equalsDart('var foo = bar[true] = false;'),
        );
      });
    }
    
    • literalList accepts an Iterable argument.

    • Fixed an NPE when a method had a return type of a FunctionType:

    void main() {
      test('should create a method with a function type return type', () {
        expect(
          new Method((b) => b
            ..name = 'foo'
            ..returns = new FunctionType((b) => b
              ..returnType = refer('String')
              ..requiredParameters.addAll([
                refer('int'),
              ]))),
          equalsDart(r'''
            String Function(int) foo();
          '''),
        );
      });
    }
    
    Source code(tar.gz)
    Source code(zip)
  • v2.1.0(Nov 4, 2017)

    We now require the Dart 2.0-dev branch SDK (>= 2.0.0-dev).

    • Added support for raw String literals.
    • Automatically escapes single quotes in now-raw String literals.
    • Deprecated File, which is now a redirect to the preferred class, Library.

    This helps avoid symbol clashes when used with dart:io, a popular library. It is now safe to do the following and get full access to the code_builder API:

    import 'dart:io';
    
    import 'package:code_builder/code_builder.dart' hide File;
    

    We will remove File in 3.0.0, so use Library instead.

    Source code(tar.gz)
    Source code(zip)
  • v2.0.0(Oct 28, 2017)

    Re-released without a direct dependency on package:analyzer!

    For users of the 1.x branch of code_builder, this is a pretty big breaking change but ultimately is for the better - it's easier to evolve this library now and even add your own builders on top of the library.

    // Copyright (c) 2017, the Dart project authors.  Please see the AUTHORS file
    // for details. All rights reserved. Use of this source code is governed by a
    // BSD-style license that can be found in the LICENSE file.
    
    import 'package:code_builder/code_builder.dart';
    import 'package:dart_style/dart_style.dart';
    
    void main() {
      final animal = new Class((b) => b
        ..name = 'Animal'
        ..extend = refer('Organism')
        ..methods.add(new Method.returnsVoid((b) => b
          ..name = 'eat'
          ..lambda = true
          ..body = const Code('print(\'Yum\')'))));
      final emitter = new DartEmitter();
      print(new DartFormatter().format('${animal.accept(emitter)}'));
    }
    

    ...outputs...

    class Animal extends Organism {
      void eat() => print('Yum!');
    }
    

    Major changes:

    • Builders now use built_value, and have a more consistent, friendly API.
    • Builders are now consistent - they don't any work until code is emitted.
    • It's possible to overwrite the built-in code emitting, formatting, etc by providing your own visitors. See DartEmitter as an example of the built-in visitor/emitter.
    • Most of the expression and statement level helpers were removed; in practice they were difficult to write and maintain, and many users commonly asked for opt-out type APIs. See the Code example below:
    void main() {
      var code = new Code('x + y = z');
      code.expression;
      code.statement;
    }
    

    See the commit log, examples, and tests for full details. While we want to try and avoid breaking changes, suggestions, new features, and incremental updates are welcome!

    Source code(tar.gz)
    Source code(zip)
  • 2.0.0-beta(Oct 24, 2017)

    2.0.0-beta

    • Added lazySpec and lazyCode to lazily create code on visit #145.

    • BUG FIX: equalsDart emits the failing source code #147.

    • BUG FIX: Top-level lambda Methods no longer emit invalid code #146.

    Source code(tar.gz)
    Source code(zip)
  • 2.0.0-alpha+3(Oct 16, 2017)

    2.0.0-alpha+3

    • Added Expression.annotation and Expression.annotationNamed.

    • Added Method.closure to create an Expression.

    • Added FunctionType.

    • Added {new|const}InstanceNamed to Expression #135.

      • Also added a typeArguments option to all invocations.
    • Added assign{...} variants to Expression #137.

    • Added .awaited and .returned to Expression #138.

    • BUG FIX: Block now implements Code #136.

    • BUG FIX: new DartEmitter.scoped() applies prefixing #139.

    • Renamed many of the .asFoo(...) and .toFoo(...) methods to single getter:

      • asCode() to code
      • asStatement() to statement
      • toExpression() to expression
    • Moved {new|const}Instance{[Named]} from Expression to Reference.

    Source code(tar.gz)
    Source code(zip)
  • 2.0.0-alpha+2(Oct 13, 2017)

    2.0.0-alpha+2

    • Upgraded build_runner from ^0.3.0 to >=0.4.0 <0.6.0.

    • Upgraded build_value{_generator} from ^1.0.0 to >=2.0.0 <5.0.0.

    • Upgraded source_gen from >=0.5.0 <0.7.0 to ^0.7.0.

    • Added MethodModifier to allow emit a Method with async|async*|sync*.

    • Added show|hide to Directive.

    • Added Directive.importDeferredAs.

    • Added a new line character after emitting some types (class, method, etc).

    • Added refer as a short-hand for new Reference(...).

      • Reference now implements Expression.
    • Added many classes/methods for writing bodies of Code fluently:

      • Expression
      • LiteralExpression
        • literal
        • literalNull
        • literalBool
        • literalTrue
        • literalFalse
        • literalNum
        • literalString
        • literalList and literalConstList
        • literalMap and literalConstMap
      • const Code(staticString)
      • const Code.scope((allocate) => '')
    • Removed SimpleSpecVisitor (it was unused).

    • Removed implements Reference from Method and Field; not a lot of value.

    • SpecVisitor<T>'s methods all have an optional [T context] parameter now.

      • This makes it much easier to avoid allocating extra StringBuffers.
    • equalsDart removes insignificant white space before comparing results.

    Source code(tar.gz)
    Source code(zip)
  • 2.0.0-alpha+1(Jul 14, 2017)

    2.0.0-alpha+1

    • Removed Reference.localScope. Just use Reference(symbol) now.
    • Allow Reference instead of an explicit TypeReference in most APIs.
      • toType() is performed for you as part the emitter process
    final animal = new Class((b) => b
      ..name = 'Animal'
      // Used to need a suffix of .toType().
      ..extend = const Reference('Organism')
      ..methods.add(new Method.returnsVoid((b) => b
        ..name = 'eat'
        ..lambda = true
        ..body = new Code((b) => b..code = 'print(\'Yum\')'))));
    
    • We now support the Dart 2.0 pre-release SDKs (<2.0.0-dev.infinity)
    • Removed the ability to treat Class as a TypeReference.
      • Was required for compilation to dart2js, which is now tested on travis.
    Source code(tar.gz)
    Source code(zip)
  • 2.0.0-alpha(Jul 14, 2017)

    2.0.0-alpha

    • Complete re-write to not use package:analyzer.
    • Code generation now properly uses the builder pattern (via built_value).
    • See examples and tests for details.
    Source code(tar.gz)
    Source code(zip)
  • 1.0.4(Jun 16, 2017)

    1.0.4

    • Added isInstanceOf to ExpressionBuilder, which performs an is check:
    expect(
      reference('foo').isInstanceOf(_barType), 
      equalsSource('foo is Bar'),
    );
    
    Source code(tar.gz)
    Source code(zip)
  • 1.0.1(Apr 5, 2017)

  • 1.0.0(Mar 31, 2017)

    1.0.0

    First full release. At this point all changes until 2.0.0 will be backwards compatible (new features) or bug fixes that are not breaking. This doesn't mean that the entire Dart language is buildable with our API, though.

    Contributions are welcome.

    • Exposed uri in ImportBuilder, ExportBuilder, and Part[Of]Builder.
    Source code(tar.gz)
    Source code(zip)
  • 1.0.0-beta+7(Mar 29, 2017)

  • 1.0.0-beta+6(Mar 16, 2017)

    1.0.0-beta+6

    • Added TypeDefBuilder.
    • Added FunctionParameterBuilder.
    • Added asAbstract to various MethodBuilder constructors.

    1.0.0-beta+5

    • Re-published the package without merge conflicts.
    Source code(tar.gz)
    Source code(zip)
  • 1.0.0-beta+4(Mar 1, 2017)

    Lots of changes in this release. Getting close to a release candidate.

    1.0.0-beta+4

    • Renamed PartBuilder to PartOfBuilder.
    • Added a new class, PartBuilder, to represent part '...dart' directives.
    • Added the HasAnnotations interface to all library/part/directive builders.
    • Added asFactory and asConst to ConstructorBuilder.
    • Added ConstructorBuilder.redirectTo for a redirecting factory constructor.
    • Added a name getter to ReferenceBuilder.
    • Supplying an empty constructor name ('') is equivalent to null (default).
    • Automatically encodes string literals with multiple lines as '''.
    • Added asThrow to ExpressionBuilder.
    • Fixed a bug that prevented FieldBuilder from being used at the top-level.
    Source code(tar.gz)
    Source code(zip)
  • 1.0.0-beta+3(Jan 31, 2017)

    1.0.0-beta+3

    • Added support for genericTypes parameter for ExpressionBuilder#invoke:
    expect(
      explicitThis.invoke('doThing', [literal(true)], genericTypes: [
        lib$core.bool,
      ]),
      equalsSource(r'''
        this.doThing<bool>(true)
      '''),
    );
    
    • Added a castAs method to ExpressionBuilder:
    expect(
      literal(1.0).castAs(lib$core.num),
      equalsSource(r'''
        1.0 as num
      '''),
    );
    

    BREAKING CHANGES

    • Removed namedNewInstance and namedConstInstance, replaced with constructor::
    expect(
      reference('Foo').newInstance([], constructor: 'other'),
      equalsSource(r'''
        new Foo.other()
      '''),
    );
    
    • Renamed named parameter to namedArguments:
    expect(
      reference('doThing').call(
        [literal(true)],
        namedArguments: {
          'otherFlag': literal(false),
        },
      ),
      equalsSource(r'''
        doThing(true, otherFlag: false)
      '''),
    );
    
    Source code(tar.gz)
    Source code(zip)
  • 1.0.0-beta+1(Jan 11, 2017)

    1.0.0-beta+1

    • Add support for switch statements
    • Add support for a raw expression and statement
      • new ExpressionBuilder.raw(...)
      • new StatemnetBuilder.raw(...)

    This should help cover any cases not covered with builders today.

    • Allow referring to a ClassBuilder and TypeBuilder as an expression
    • Add support for accessing the index [] operator on an expression

    BREAKING CHANGES

    • Changed ExpressionBuilder.asAssign to always take an ExpressionBuilder as target and removed the value property. Most changes are pretty simple, and involve just using reference(...). For example:
    literal(true).asAssign(reference('flag'))
    

    ... emits flag = true.

    Source code(tar.gz)
    Source code(zip)
  • 1.0.0-beta(Jan 5, 2017)

    1.0.0-beta

    • Add support for async, sync, sync* functions
    • Add support for expression asAwait, asYield, asYieldStar
    • Add toExportBuilder and toImportBuilder to types and references
    • Fix an import scoping bug in return statements and named constructor invocations.
    • Added constructor initializer support
    • Add while and do {} while loop support
    • Add for and for-in support
    • Added a name getter for ParameterBuilder
    Source code(tar.gz)
    Source code(zip)
  • 1.0.0-alpha+6(Nov 22, 2016)

  • 1.0.0-alpha+5(Nov 21, 2016)

  • 1.0.0-alpha+4(Nov 19, 2016)

Owner
Dart
Dart is an open-source, scalable programming language, with robust libraries and runtimes, for building web, server, and mobile apps.
Dart
Scaff is a simple command-line utility for generating Dart and Flutter components from template files.

Introduction Scaffold Generator for Dart and Flutter. scaff is a simple command-line utility for generating Dart and Flutter components from template

Ganesh Rathinavel Medayil 29 Jul 17, 2022
Protofu is a Dart Command Line tool for generating your protobufs and included dependencies in one command.

ProtoFu - let me compile that for you ProtoFu exists to make working with protobufs easier. Gone are the days of downloading protoc and the dart proto

John McDole 5 Oct 27, 2022
ANSI escape sequences and styling micro-library written in fluent/modern Dart.

neoansi ANSI escape sequences and styling micro-library written in fluent/modern Dart. This library provides minimal ANSI escape sequences and helpers

Neo Dart 8 Oct 31, 2022
Launcher for the reboot project written with Dart(Flutter) and Fluent UI compliant

reboot_launcher Launcher for project reboot Getting Started This project is a starting point for a Flutter application. A few resources to get you sta

Alessandro Autiero 3 Oct 22, 2022
A flutter plugin about qr code or bar code scan , it can scan from file、url、memory and camera qr code or bar code .Welcome to feedback your issue.

r_scan A flutter plugin about qr code or bar code scan , it can scan from file、url、memory and camera qr code or bar code .Welcome to feedback your iss

PengHui Li 112 Nov 11, 2022
Implements Microsoft's Fluent Design System in Flutter.

fluent_ui Design beautiful native windows apps using Flutter Unofficial implementation of Fluent UI for Flutter. It's written based on the official do

Bruno D'Luka 1.8k Dec 29, 2022
Fluent System Icons are a collection of familiar, friendly and modern icons from Microsoft.

Fluent UI System Icons Fluent UI System Icons are a collection of familiar, friendly and modern icons from Microsoft. Icon List View the full list of

Microsoft 4.3k Dec 29, 2022
A Flutter package for generating sign in buttons for different social media accounts.

Sign In Button A Flutter plugin for generating sign in buttons for different social media accounts. Getting Started You must add the library as a depe

null 42 Dec 8, 2022
Bhagavad Gita app using flutter & Bhagavad-Gita-API is A lightweight Node.js based Bhagavad Gita API [An open source rest api on indian Vedic Scripture Shrimad Bhagavad Gita].

Gita Bhagavad Gita flutter app. Download App - Playstore Web Application About Bhagavad Gita app using flutter & Bhagavad-Gita-API is A lightweight No

Ravi Kovind 7 Apr 5, 2022
Automatic source code generation for Dart

Overview source_gen provides utilities for automated source code generation for Dart: A framework for writing Builders that consume and produce Dart c

Dart 418 Dec 30, 2022
Beautiful Weather App using API with support for dark mode. Created by Jakub Sobański ( API ) and Martin Gogołowicz (UI, API help)

Flutter Weather App using API with darkmode support Flutter 2.8.1 Null Safety Beautiful Weather App using https://github.com/MonsieurZbanowanYY/Weathe

Jakub Sobański 5 Nov 29, 2022
Enum extendable - Dart code generator. Generates enum extensions code.

Generates code for the extension on an enum. Overview Being able to add fields and methods to an enum. Let's say we have the following enum: enum Math

null 0 Jan 10, 2022
Write iOS&Android Code using Dart. This package liberates you from redundant glue code and low performance of Flutter Channel.

Dart_Native Dart_Native operates as both a code generator tool and a bridge to communicate between Dart and native APIs. Replaces the low-performing F

DartNative 893 Jan 4, 2023
Shader manages the compilation of your GLSL shaders into SPIR-V byte code and Dart code

shader Shader manages the compilation of your GLSL shaders into SPIR-V byte code and Dart code. Quickstart # Install cli dart pub global activate shad

Felix Blaschke 25 Dec 1, 2022
Repository containing source code for the tutorials made using with flutter

Flutter Tutorials Repository Containing Source code for tutorials found here: https://petercoding.com Note: Don't forgot to run pub get or just open p

Peter Haddad 19 Dec 9, 2022
The repo contains the source code for all the tutorials on the FilledStacks Youtube channel.

Flutter tutorials The repo contains the source code for all the written tutorials by Filledstacks. All Tutorials plus additional snippets and shorter

Dane Mackier 4.5k Dec 31, 2022
PalestineDevelopers is an open-source tools code-base

PalestineDevelopers مبادرة لإحياء إسم فلسطين بتقديم أدوات برمجية تحمل إسم أرض الميعاد Flutter Packages .. will be replaced .. will be replaced .. will

Mohamed Sayed 10 Jan 4, 2022
Fluttery - the source code of a quiz app about Flutter

Fluttery This repository aims to store the source code of a quiz app about Flutt

Naomi Lago 3 May 11, 2022
Source code for login demo in Coding with Flutter series

Flutter & Firebase Authentication demo Source code based on my Flutter & Firebase Authentication video series: Part 1 Part 2 Part 3 Part 4 Part 5 Part

Andrea Bizzotto 162 Dec 29, 2022