gtgalone / currency_text_input_formatter

Currency Text Input Formatter for Flutter.
https://pub.dev/packages/currency_text_input_formatter
MIT License
50 stars 28 forks source link

Value alignment #17

Closed iksent closed 3 years ago

iksent commented 3 years ago

I am passing formatter to inputFormatters like this:

CurrencyTextInputFormatter(
  decimalDigits: 2,
  symbol: '',
  locale: 'ru',
),

Trying to input integer number like "123", but getting "1,23" - This behavior is very uncomfortable for users.

This will be great to have a prop to control it and allow users to enter decimals manually with dot or comma. This is like autonumeric works: http://autonumeric.org/

gtgalone commented 3 years ago

@iksent Thank you for using.

Can you try without decimalDigits: 2 with 2.0.1 version which is released today ?

iksent commented 3 years ago

Not yet, waiting for other libs to be compatible with nullsafety. Will definitely try asap and come back with a news!

So in 2.0.1 the behavior was changed?

You wrote "without decimalDigits: 2", but how can I control count of digits? I want to save the ability of decimals (I need percentage from 0 to 100 with decimals like 12.34%, 12.3% or just 12%)

gtgalone commented 3 years ago

Oh That percentage needs to set decimalDigits.

I mean, from 2.0.1 version, formatter is working based on locale.

If you are using Euro. It uses , for decimal automatically.

iksent commented 3 years ago

You have probably didn't understand my issue :(

The problem is that, with "decimalDigits = N" I am trying to input "123", but getting "1,23" (value is being aligned from right to left), so i need to put extra "00" to get "123.00". But I don't want to get "123.00", I just want to get "123". I want users to decide, whether they need decimals or not. If not - then they will enter integer number, if yes - they should manually enter dot or comma to add a decimals after it.

gtgalone commented 3 years ago

Yes. I understood.

If you want to remove decimal, just pass argument decimalDigits: 0. You can get 123 without .00

So you can try with CurrencyTextInputFormatter(symbol: '',locale: 'ru', decimalDigits: 0).

It return just 123 without any decimal something. (2.0.1 version only)

And you can try with unsound null safety with --no-sound-null-safety flag.

iksent commented 3 years ago

No - I don't want to remove decimals - this is a problem! :) I want to save the ability of decimals. Please see http://autonumeric.org/, here is an example at this site (user starts to input from left to right and not from right to left, as currency_text_input_formatter has now).

I want the ability to input: 12.34%, 12.3% or just 12% (Not 12.00!) at the same time.

gtgalone commented 3 years ago

Oh now I understand.

I use rates field for RegExp FilteringTextInputFormatter.allow(RegExp(r'^\d*\.?\d*$')).

This is for currency. However, I will figure it out.

But dynamic decimal is impossible, because I use NumberFormat.currency of Intl package.

decimal must be initialized. If so, maybe possible :)

iksent commented 3 years ago

The main problem for me is just not a dynamic decimal (it can be fixed for my purposes), but input "alignment" - users start to enter a value from decimals and need to add extra "00" to get an integer like "12,00"...