dart-lang / tools

This repository is home to tooling related Dart packages.
BSD 3-Clause "New" or "Revised" License
30 stars 22 forks source link

Would like a (typeless) parameter shorthand. #1124

Open eseidel opened 1 year ago

eseidel commented 1 year ago

AFAICT, the shortest way to add (foo) to your parameter list is Parameter((b) => b..name = 'foo', feels like there could be something shorter? Maybe there is an I just didn't find it in the code?

eseidel commented 1 year ago

For example (and maybe this is a separate issue?) Is this the shortest way to write (value) => value.toJson()?

    var toJson = Method((m) => m
      ..requiredParameters.add(Parameter((p) => p.name = 'value'))
      ..body = refer('value').property('toJson').call([]).code).closure;
eseidel commented 1 year ago

I guess var toJson = Code('(value) => value.toJson()'); is the right way. :)