dart-lang / code_builder

A fluent API for generating valid Dart source code
https://pub.dev/packages/code_builder
BSD 3-Clause "New" or "Revised" License
423 stars 66 forks source link

Allow defining an EnumValue with named parameters #397

Open SamJakob opened 1 year ago

SamJakob commented 1 year ago

It doesn't appear possible to do this with code_builder and the functionality within Flutter to do this is relatively new. In terms of an example:

//...
return EnumValue((builder) {
  b.name = 'example';
  b.arguments.add(literal("Some argument"));

  b.arguments.add(literal("Some other argument"), name: "test");
  // or alternatively, b.namedArguments could be added to EnumValueBuilder.
});
//...

Where this might result in the following:

// ...

  example("Some argument", test: "Some other argument"),

// ...