Flutter 中的拨打电话号码功能

问题描述 投票:0回答:2

我设计了一个功能来拨打按下图标上的号码。 但它无法启动网址

 _callMe() async {
 print("Phone +91${store_phone}");
 var uri = 'tel:+91${store_phone}';
 if (await canLaunch(uri)) {
   await launch(uri);
 } else {
   throw 'Could not launch $uri';
 }
}

打印错误 未处理的异常:无法启动+919919195521

大家有什么帮助吗?

flutter flutter-layout flutter-dependencies flutter-web flutter-animation
2个回答
0
投票

尝试下面的代码希望对您有所帮助。使用 url_launcher

Padding(
  padding: EdgeInsets.only(top: 18.0),
  child: InkWell(
    child: Text(
      ' +91 888-888-8888',
      style: TextStyle(
        fontSize: 15,
        color: Colors.blue,
      ),
    ),
    onTap: () => launch('tel:${8888888888}'),
  ),
)

0
投票
 Uri numberUri;
     numberUri = Uri(scheme: 'tel', path: phoneNumber);

    if (!await launchUrl(numberUri)) throw 'Could not launch $numberUri';
''''
Use the above method to open phone dialer
© www.soinside.com 2019 - 2024. All rights reserved.