Skip to content
This repository was archived by the owner on Apr 8, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## 4.6.0-wip

* Add support for named arguments in `enum` classes
* Add support for external keyword on fields.

## 4.5.0

Expand Down
3 changes: 3 additions & 0 deletions lib/src/emitter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,9 @@ class DartEmitter extends Object
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
6 changes: 6 additions & 0 deletions lib/src/specs/field.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ abstract class Field extends Object
/// Whether this field should be prefixed with `late`.
bool get late;

/// Whether the field should be prefixed with `external`.
bool get external;

/// Name of the field.
String get name;

Expand Down Expand Up @@ -86,6 +89,9 @@ abstract class FieldBuilder extends Object
/// Whether this field should be prefixed with `late`.
bool late = false;

/// Whether the field should be prefixed with `external`.
bool external = false;

/// Name of the field.
String? name;

Expand Down
22 changes: 22 additions & 0 deletions lib/src/specs/field.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions test/specs/field_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,18 @@ void main() {
'''),
);
});

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