dart-decimal icon indicating copy to clipboard operation
dart-decimal copied to clipboard

Implement isNegative property

Open adamstyrc opened this issue 3 years ago • 1 comments

When calling NumberFormat.format() with Decimal as an argument, there is

NoSuchMethodError
Class 'Decimal' has no instance getter 'isNegative'.
Receiver: Instance of 'Decimal'
Tried calling: isNegative

It would be great to have isNegative property (getter) added as other num do have it :)

adamstyrc avatar Sep 29 '22 11:09 adamstyrc

Do you have a particular value of decimal to reproduce this error?

a14n avatar Sep 29 '22 12:09 a14n

final decimal = Decimal.fromInt(1000);
final formatter = NumberFormat(
      "0.0##",
      "en_US",
    );
formatter.format(decimal);

I guess something like this causes the error but the formatter should be called like this

formatter.format(DeicmalIntl(decimal));

felix-larsen avatar Jan 30 '23 23:01 felix-larsen