The TextField is coded below to only allow digits, decimal and dash (negative number).
Textfield的编码如下,仅允许数字、小数和破折号(负数)。
child: TextField(
decoration: const InputDecoration(
border: OutlineInputBorder(),
labelText: 'Enter the answer',
),
controller: _controller,
textAlign: TextAlign.center,
keyboardType: const TextInputType.numberWithOptions(
decimal: true,
signed: false,
),
inputFormatters: <TextInputFormatter>[
FilteringTextInputFormatter.allow(
RegExp('[0-9.-]'),
),
],
),
However, emulator and devices shows differently (dash is missing, Samsung device uses default Samsung keyboard)
Using GBoard in the Samsung device will solve the issue.
然而,模拟器和设备显示不同(破折号丢失,三星设备使用默认的三星键盘)在三星设备中使用Gboard将解决这个问题。
What is the best practice to solve this issue since other user might have different phone models/keyboards?
由于其他用户可能具有不同的手机型号/键盘,解决此问题的最佳实践是什么?
Thanks
谢谢
更多回答
优秀答案推荐
我是一名优秀的程序员,十分优秀!