重要提示:请注意,该mobile_number插件需要非常特殊的权限才能拨打电话。
sms_autofill 根本不询问任何权限。像这样使用它:
@override
void initState() {
super.initState();
Future<void>.delayed(const Duration(milliseconds: 300), _tryPasteCurrentPhone);
}
Future _tryPasteCurrentPhone() async {
if (!mounted) return;
try {
final autoFill = SmsAutoFill();
final phone = await autoFill.hint;
if (phone == null) return;
if (!mounted) return;
_textController.value = phone;
} on PlatformException catch (e) {
print('Failed to get mobile number because of: ${e.message}');
}
}
Run Code Online (Sandbox Code Playgroud)
小智 8
dart 酒吧中的这个图书馆似乎可以满足您的需求。检查下面链接的包:
https://pub.dev/packages/sms_autofill
PhoneFieldHint [仅限安卓]
final SmsAutoFill _autoFill = SmsAutoFill();
final completePhoneNumber = await _autoFill.hint;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2238 次 |
| 最近记录: |