Skip to content

joutvhu/number_text_input_formatter

Repository files navigation

Number Text Input Formatter

Number Text Input Formatter for Flutter.

Installation

# Add into pubspec.yaml
dependencies:
  number_text_input_formatter: ^lastVersion

Usage

For number

TextField(
  inputFormatters: [
    NumberTextInputFormatter(
      integerDigits: 10,
      decimalDigits: 2,
      maxValue: '1000000000.00',
      decimalSeparator: '.',
      groupDigits: 3,
      groupSeparator: ','
      allowNegative: false,
      overrideDecimalPoint: true,
      insertDecimalPoint: false,
      insertDecimalDigits: true,
    ),
  ],
  keyboardType: TextInputType.number,
),

For currency

TextField(
  inputFormatters: [CurrencyTextInputFormatter()],
  keyboardType: TextInputType.number,
),

For percentage

TextField(
  inputFormatters: [PercentageTextInputFormatter()],
  keyboardType: TextInputType.number,
),