ferraridamiano / units_converter

Pure Dart package to easily convert units of mesurement, numeral systems and custom units.
https://pub.dev/packages/units_converter
MIT License
29 stars 15 forks source link

Conversion with num extension #20

Closed ferraridamiano closed 2 years ago

ferraridamiano commented 2 years ago

Developer that need to convert just one unit to another needs to write a little bit of boilerplate code:

var length = Length()..convert(LENGTH.meters, 1); // We give 1 meter as input
var unit = length.inches; // We get the inches

If we implement num extension we would get something much simpler:

1.convertFromTo(LENGTH.meters, LENGTH.inches)

This should be just an addition to the current API, not a replacement!