money_field 1.0.1
money_field: ^1.0.1

Flutter Android iOS web

A simple to use TextEditingController for handling money values.

Money Field #

A simple to use TextEditingController for handling money values.

Install #

1. Add money_field to your pubspec.yaml: #

dependencies:
    money_field: ^1.0.0

2. Install it #

flutter packages get

3. Import it: #

import 'package:money_field/money_field.dart';

Usage #

final _moneyFieldController = MoneyFieldController();

...

TextFormField(
    controller: _moneyFieldController,
    keyboardType: TextInputType.number,
),

Customization Options #

final _moneyFieldController = MoneyFieldController(
    decimalSeparator = '.',
    thousandsSeparator = ',',
    invalidFormatError = 'Invalid input format',
    invalidLengthError = 'Length must be less than or equal to 9',
    maxDigitsBeforeDecimal = 9
);

Convert Input to Double #

final _moneyFieldController = MoneyFieldController();

var doubleValue = _moneyFieldController.doubleValue();

Field Validation #

final _moneyFieldController = MoneyFieldController();

TextFormField(
    controller: _moneyFieldController,
    keyboardType: TextInputType.number,
    validator: (_) {
        return _moneyFieldController.moneyFieldValidator();
    },
),

Check if Input is Valid #

If you'd just like to check if the input is valid, without using the validator, you can:

final _moneyFieldController = MoneyFieldController();

bool isFormatValid = _moneyFieldController.isFormatValid();
bool isLengthValid = _moneyFieldController.isLengthValid();

// Checks if format and length are valid
bool isValid = _moneyFieldController.isInputValid();

Issues #

If you encounter any issues, feel free to post them on the GitHub page.

1
likes
90
pub points
65%
popularity

A simple to use TextEditingController for handling money values.

Repository (GitHub)
View/report issues

Documentation

API reference

Uploader

emgrandt@gmail.com

License

MIT (LICENSE)

Dependencies

flutter

More

Packages that depend on money_field