Skip to content
This repository has been archived by the owner on Nov 1, 2024. It is now read-only.

v2.2.0

Compare
Choose a tag to compare
@matanlurey matanlurey released this 22 Nov 05:04
· 186 commits to master since this release
8d2ee42
  • 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();
      '''),
    );
  });
}