flutter url_launcher 包不适用于 iOS 设备

flutter url_launcher package is not working for iOS devices

我正在为我的项目使用 flutter url_launcher: ^6.0.20。但它不适用于 iOS 设备,但它可以毫无问题地用于 android 设备。

Column(
      mainAxisAlignment: MainAxisAlignment.center,
       children: [
        GestureDetector(
        onTap: () async {
        final contact = contactNumber;
        await launch('tel:$contact');
                               
       },
       child: Row(
              mainAxisAlignment: MainAxisAlignment.center,
              children: [
               const Text(
                'Hotline - ',
                style: TextStyle(
                fontSize: 25.0,
                fontWeight: FontWeight.bold,
                                       
                ),
              ),
             Text(
              contactNumber,
              style: const TextStyle(
                     fontSize: 25.0,
                     fontWeight: FontWeight.bold,
                     decoration: TextDecoration.underline),
                     ),
                   ],
                 ),
              ),

contactNumber 来自后端 api。我已将该值分配给 contactNumber 变量。

下面是包裹,

https://pub.dev/packages/url_launcher

它在 android 上正常工作。不适用于 iOS。代码没有错误。是不是包的问题?

试一试,对我有用launch("tel://1234567890");

创建调用方法。

 Future<void> _makePhoneCall(String phoneNumber) async {
  final Uri launchUri = Uri(
  scheme: 'tel',
  path: phoneNumber,
  );
await launchUrl(launchUri);
 }

然后调用 onPressed:

_makePhoneCall("01*********");

don't forget to add permission on info.plist.

if you add dependency on runtime, it may be not working. So stop the run and build the project again