Skip to content
This repository was archived by the owner on Apr 8, 2025. It is now read-only.

Commit 0f3f943

Browse files
authored
Add an example of generating an anonymous closure (#384)
This fixes https://github.com/dart-lang/code_builder/issues/381.
1 parent a1f7b0a commit 0f3f943

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

test/specs/method_test.dart

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -590,4 +590,19 @@ void main() {
590590
'''),
591591
);
592592
});
593+
594+
test('should create a method as a closure', () {
595+
expect(
596+
Method(
597+
(b) => b
598+
..requiredParameters.add(
599+
Parameter((b) => b..name = 'a'),
600+
)
601+
..body = const Code(''),
602+
).closure,
603+
equalsDart(r'''
604+
(a) { }
605+
'''),
606+
);
607+
});
593608
}

0 commit comments

Comments
 (0)