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

Does code_builder support a notion of target language version? #378

Open yanok opened 1 year ago

yanok commented 1 year ago

Or is it completely up to the user to make sure to only use the supported constructs?

Sometimes (the particular case I'm having at hand is required named arguments) it's possible to handle unsupported constructs gracefully, so for example if a required named argument were requested via builder, the library can generate an actual required arg if version >=2.12 is requested, and just drop the required otherwise.