Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions pkgs/code_builder/lib/src/emitter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -437,15 +437,15 @@ class DartEmitter extends Object
for (var a in spec.annotations) {
visitAnnotation(a, output);
}
if (spec.external) {
output.write('external ');
}
if (spec.static) {
output.write('static ');
}
if (spec.late && _useNullSafetySyntax) {
output.write('late ');
}
if (spec.external) {
output.write('external ');
}
switch (spec.modifier) {
case FieldModifier.var$:
if (spec.type == null) {
Expand Down
30 changes: 30 additions & 0 deletions pkgs/code_builder/test/specs/field_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,34 @@ void main() {
'''),
);
});

test('should create a late static field', () {
expect(
Field((b) => b
..name = 'value'
..static = true
..late = true
..type = refer('String')
..annotations.addAll([refer('JS').call([])])),
equalsDart(r'''
@JS()
static late String value;
''', DartEmitter(useNullSafetySyntax: true)),
);
});

test('should create an external static field', () {
expect(
Field((b) => b
..name = 'value'
..external = true
..static = true
..type = refer('double')
..annotations.addAll([refer('JS').call([])])),
equalsDart(r'''
@JS()
external static double value;
'''),
);
});
}
Loading