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
427 stars 66 forks source link

Impossible to force literalNum(10.0) to be a double #345

Open m0nac0 opened 2 years ago

m0nac0 commented 2 years ago

If I use literalNum(10.0), the result will be 10. But I need to make sure the result is a double, i.e. has at least one decimal digit. Is there any way to achieve that? If not, maybe something like this: Expression literalDouble(double value) => LiteralExpression._(value.toString()); could be added to literal.dart? If I understand the docs for double.toString() correctly, that should ensure that at least one decimal digit is included in the output. Thank you!