简体   繁体   English

Flutter 在使用文本输入时仅显示 0-9 键盘而不是扩展数字键盘(即所有 ascii 字符都应该可用)

[英]Flutter showing only 0-9 keypad instead of extended number keypad when using text input (i.e. all ascii characters should be available)

In my flutter app, I cannot get the full numeric keypad (0-9 + "top row" characters like,,@,# etc) to appear, even when using在我的 flutter 应用程序中,即使使用

keyboardType: TextInputType.text

I've included screenshots below of what I want vs. what I get.我在下面包含了我想要的与我得到的截图。

When I open the keyboard in flutter in iOS当我在 iOS 中打开 flutter 中的键盘时

在此处输入图像描述

I Get This我明白了

在此处输入图像描述

But I Want This但我想要这个

在此处输入图像描述

This is my code这是我的代码

TextField(
            key: key,
            style: textStyle,
            textAlign: TextAlign.center,
            controller: textFieldController,
            cursorColor: selectedColor,
            keyboardType: TextInputType.text,
            onChanged: onChanged )

I would suggest trying to run the app without specifying the keyboardtype.我建议尝试在不指定键盘类型的情况下运行该应用程序。 When I recreated the text field and specified the keyboardtype to textinputtype.text, I also got the same output, but when I ran the app without specifying the keyboardtype my keyboard was fine.当我重新创建文本字段并将键盘类型指定为 textinputtype.text 时,我也得到了相同的 output,但是当我在未指定键盘类型的情况下运行应用程序时,我的键盘很好。 This is my first contribution, so please let me know if it fixed the issue for you.这是我的第一个贡献,如果它为您解决了问题,请告诉我。

The Fix修复

  1. Be sure you are on stable channel (unless you have a good reason not to be)确保您在稳定的频道上(除非您有充分的理由不这样做)

flutter channel flutter通道

be sure you are on stable (I was on master)确保您处于稳定状态(我在 master 上)

  1. Use Flutter 1.17.5 or higher.使用 Flutter 1.17.5 或更高版本。 You can find out your version with.你可以找到你的版本。

flutter --version flutter --版本

To get it you can set keyboardType要获得它,您可以设置keyboardType

for example例如

keyboardType: TextInputType.numberWithOptions(signed: true, decimal: true)

this will give this look这会给你这个样子

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM