Missing number input controller for flutter apps
- formats as-you-type text fields as numbers (decimals, currency or integers)
- extracts
num
value from the input - an example with
final controller = NumberEditingTextController.currency(currencyName: 'JPY');
controller
- install the library
flutter pub add number_editing_controller
Working example can be found in /example directory
- first you should define your controller
final controller = NumberEditingTextController.integer();
final controller = NumberEditingTextController.decimal();
final controller = NumberEditingTextController.currency();
-
optionally you can provide
locale
to use locale-based formatting -
for
currency()
there's alsocurrencyName
andcurrencySymbol
parameters available -
you can set
allowNegative
tofalse
to allow only unsigned input -
set this
controller
as the controller for the targetTextField
-
now the
TextField
would filter out all non-integer symbols -
you can extract the value with
controller.number