How to create number input field in Flutter?

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

    Here is code for numeric keyboard : keyboardType: TextInputType.phone When you add this code in textfield it will open numeric keyboard.

      final _mobileFocus = new FocusNode();
      final _mobile = TextEditingController();
    
    
         TextFormField(
              controller: _mobile,
              focusNode: _mobileFocus,
              maxLength: 10,
              keyboardType: TextInputType.phone,
              decoration: new InputDecoration(
                counterText: "",
                counterStyle: TextStyle(fontSize: 0),
                hintText: "Mobile",
                border: InputBorder.none,
                hintStyle: TextStyle(
                  color: Colors.black,
                    fontSize: 15.0.
                ),
              ),
              style: new TextStyle(
                  color: Colors.black,
                  fontSize: 15.0,
               ),
              );
    

提交回复
热议问题