0

我有一个 TextField 用于在我的颤振应用程序中获得双精度。TextField 使用数字键盘。

   child: TextField(
        style: TextStyle(color: Colors.white),
        inputFormatters: [FilteringTextInputFormatter.allow(new RegExp("[0-9.]"))],
        controller: controller,
        keyboardType: TextInputType.number,
        decoration: textDecorator,
        onSubmitted: () {
          //Some Action
        },
      ),

我使用 inputformatter 来防止用户点击代码中显示的其他标点符号。我的问题是我可以输入类似“23.45.3”的内容,基本上有两个“。” 不应该被允许的符号。理想情况下,如果用户尝试单击“.”,则在“23.”之后。从键盘再次它应该被禁用。任何有关如何做到这一点的帮助表示赞赏。

4

0 回答 0