Skip to content

Add explicitSign parameter to all NumberFormats #940

Open
@Albert221

Description

@Albert221

Is your feature request related to a problem? Please describe.
Let's say I'm building an app that shows a number difference, percentage or just a number. If the number is positive, I want to have the plus sign.

Describe the solution you'd like
NumberFormat.decimalPattern, .decimalPatternDigits, .decimalPercentPattern, percentPattern, simpleCurrency, currency, compactCurrency, the default constructor and maybe the scientificPattern (here I'm not sure) shall all have explicitSign constructor parameter. If they can display a minus sign for negative numbers, I don't see why only compact formats should be able to also show a plus sign for non-negative numbers. And this should be a constructor parameter and not only a mutable property on the NumberFormat, because I want to use this not only in code but also in flutter gen-l10n with ARB format and optionalParameters where I could set this flag to true.

Describe alternatives you've considered
Keeping two translation keys, one with a hardcoded plus sign, or passing a string to the translation, with a manually added plus sign.

Additional context
https://pub.dev/documentation/intl/latest/intl/NumberFormat-class.html

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions