gpt4 book ai didi

flutter : url_launcher exception

转载 作者:IT王子 更新时间:2023-10-29 06:44:06 33 4
gpt4 key购买 nike

我正在使用 url_launcher 依赖项在我的一个图标上具有拨号功能;然而,这适用于 Android 而不是 IOS?

调用启动器方法是:

   _launchcaller()  async
{
const url = '719-282-2224';

if (await canLaunch(url))
{
await launch(url);
}

else{
throw 'Could not launch $url';
}

}

然后我在 onTap 监听器上调用该方法,如下所示:

new GestureDetector(

onTap: _launchcaller,

child: new Icon(Icons.phone, color: Colors.blue, size: 50.0,),

),

异常输出:

[VERBOSE-2:dart_error.cc(16)] Unhandled exception:
Could not launch tel:719-282-2224
#0 angryScreenState._launchcaller (file:///Users/ielbouyahyaouy/AndroidStudioProjects/app_firebase/flutter_app_books/lib/angryScreen.dart:103:7)
<asynchronous suspension>
#1 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:102:24)
#2 TapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:161:9)
#3 TapGestureRecognizer.handlePrimaryPointer (package:flutter/src/gestures/tap.dart:94:7)
#4 PrimaryPointerGestureRecognizer.handleEvent (package:flutter/src/gestures/recognizer.dart:315:9)
#5 PointerRouter._dispatch (package:flutter/src/gestures/pointer_router.dart:73:12)
#6 PointerRouter.route (package:flutter/src/gestures/pointer_router.dart:101:11)
#7 _WidgetsFlutterBinding&BindingBase&GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:143:19)
#8 _WidgetsFlutterBinding&BindingBase&GestureBinding.dispatchEvent (packag<…>

最佳答案

要让 iOS 设备将 url 理解为电话号码,您需要去掉破折号。你可以这样做。它也应该以 tel://为前缀

url = 'tel://719-282-2224';
url = url.replaceAll(new RegExp(r'-'), ''); // remove dashes

关于 flutter : url_launcher exception,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51564543/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com