首页 > 解决方案 > Flutter AutofillHints oneTimeCode 不起作用

问题描述

我想捕捉 OTP 短信代码,但它在 IOS 上不起作用。我需要显示键盘上方的代码。

我的代码块是;

TextField(
 controller: controller,
 autofillHints: const <String>[AutofillHints.oneTimeCode],
 keyboardType: TextInputType.number,
 onChanged: onChanged,
),

标签: flutterdarttextfieldone-time-password

解决方案


来自https://master-api.flutter.dev/flutter/material/TextField/autofillHints.html上的 Flutter 文档“某些自动填充提示仅适用于特定的键盘类型”。尝试更改键盘类型。例如:

TextField(
 controller: controller,
 autofillHints: const <String>[AutofillHints.oneTimeCode],
 keyboardType: TextInputType.text,
 onChanged: onChanged,
),

推荐阅读