How to create number input field in Flutter?

后端 未结 14 2099
被撕碎了的回忆
被撕碎了的回忆 2020-12-12 21:47

I\'m unable to find a way to create an input field in Flutter that would open up a numeric keyboard. Is this possible with Flutter material widgets? Some github discussions

14条回答
  •  失恋的感觉
    2020-12-12 22:14

    For those who need to work with money format in the text fields:

    To use only: , (comma) and . (period)

    and block the symbol: - (hyphen, minus or dash)

    as well as the: ⌴ (blank space)

    In your TextField, just set the following code:

    keyboardType: TextInputType.numberWithOptions(decimal: true),
    inputFormatters: [BlacklistingTextInputFormatter(new RegExp('[\\-|\\ ]'))],
    

    The simbols hyphen and space will still appear in the keyboard, but will become blocked.

提交回复
热议问题