How to create number input field in Flutter?

后端 未结 14 2106
被撕碎了的回忆
被撕碎了的回忆 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 21:48

    You can use this two attributes together with TextFormField

     TextFormField(
             keyboardType: TextInputType.number
             inputFormatters: [WhitelistingTextInputFormatter.digitsOnly],
    

    It's allow to put only numbers, no thing else ..

    https://api.flutter.dev/flutter/services/TextInputFormatter-class.html

提交回复
热议问题