gtgalone/currency_text_input_formatter

Format default value in TextFormField

chitgoks opened this issue · 2 comments

hi. how can it be formatted by default? this is my code

TextFormField(
                        decoration: InputDecoration(labelText: tr('premium')),
                        enabled: connectivityResult != ConnectivityResult.none,
                        initialValue: _policy?.premium == 0 ? '' : _policy?.premium.toString(),
                        inputFormatters: [ CurrencyTextInputFormatter(symbol: '') ],
                        keyboardType: TextInputType.numberWithOptions(decimal: true),
                        textInputAction: TextInputAction.next,
                        validator: (String? value) {
                          return value!.isEmpty ? tr('premium_blank') : null;
                        },
                        onChanged: (value) {
                          if (value.replaceAll(',', '').length > 0)
                            _policy?.premium = double.parse(value.replaceAll(',', ''));
                        },
                      ),

The lib works ok when typing. but when it's loaded, it doesnt do any formatting.

Hi, how did you managed this?

Hi, how did you managed this?

sorry, what? what do you mean how i managed this?