如何从Flutter拨打电话? [英] How can I dial the phone from Flutter?

查看:433
本文介绍了如何从Flutter拨打电话?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建Flutter应用程序,我想拨打电话以响应按钮的点击.最好的方法是什么?

I am building a Flutter app, and I'd like to dial a phone number in response to a button tap. What's the best way to do this?

谢谢!

推荐答案

通常,要与基础平台进行交互,您必须编写平台特定的代码,并使用 UrlLauncher.launch API使用tel方案拨打电话.

Typically, to interact with the underlying platform, you have to write platform specific code and communicate with the same using platform channels. However, Flutter provides some points of integration with the platform out of the box. To dial the phone for instance, you can use the UrlLauncher.launch API with the tel scheme to dial the phone.

类似UrlLauncher.launch("tel://<phone_number>");的东西在所有平台上都可以正常工作.

Something like UrlLauncher.launch("tel://<phone_number>"); should work fine on all platforms.

请注意,这在模拟器中不起作用.因此,请确保您使用的是实际设备来对此进行测试.

Do note that this will not work in the simulators. So make sure you are using an actual device to test this.

这篇关于如何从Flutter拨打电话?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆