当我点击联系卖家按钮,然后它打开网页,它显示网页不可用网页在什么应用程序://发送/?电话= 923424627671&text = Hi%2C%20I%20am%20感兴趣的%20in%20the%20产品%3A%0A%0A产品%20名称%3A%20Electric%20%0A产品%20图像%3A%20https%3A%2F%2Ffirebasestorage.googleapis.com%2Fv0%2Fb%2Fecommerce-1b43e.appspot.com%2Fo%2Fimages1677497513119374%3Falt%3Dmedia&type =电话号码& app_absent = 0无法加载,因为:
net::ERR_UNKNOWN_URL_SCHEME在控制台中,当我点击链接时,它会转到WhatsApp的网页,当我点击继续聊天时,它会发送消息,但在物理移动设备中,它会给出上述错误或网页视图添加是mendory?而在应用程序中,当我点击返回时,它会显示WhatsApp的网页一会儿,但它不会永久打开为什么?有人能解决这个错误吗?这里是我的代码
String buildWhatsAppMessage() {
String message = 'Hi, I am interested in the product:\n\n';
message += 'Product Name: ${widget.productName}\n';
message += 'Product Image: ${widget.url}\n';
message += 'Product Price: ${widget.productPrice}\n\n';
message += 'Please let me know more about it.';
return Uri.encodeFull(message);
}
void launchWhatsApp() async {
String phoneNumber = 'https://wa.me/${widget.phonenumber}?text=${buildWhatsAppMessage()}';
if (await canLaunchUrl(Uri.parse(phoneNumber))){
launchUrl(Uri.parse(phoneNumber));
} else {
showDialog(context: context,
builder: (BuildContext context) {
return AlertDialog(
title: Text('Seller has no WhatsApp number'),
content: Text('Unfortunately, the seller does not have a WhatsApp account.'),
actions: [
ElevatedButton(
child: Text('OK'),
onPressed: () {
Navigator.of(context).pop();
},
),
],
);
});
}
}
RoundedLoadingButton(
child: Text(
'Contact with seller',
style: TextStyle(color: Colors.white),
),
controller: contact,
resetDuration: Duration(seconds: 3),
resetAfterDuration: true,
width: 200,
height: 50,
color: Colors.blue,
successColor: Colors.blue,
borderRadius: 10,
elevation: 3,
onPressed: _isAddToContactLoading
? null
: () async {
setState(() {
_isAddToContactLoading = true;
});
launchWhatsApp();
setState(() {
_isAddToContactLoading = false;
});
_addCartController.success();
},
),
1条答案
按热度按时间kqlmhetl1#
添加模式外部应用程序
还要确保查询元素必须作为根元素的子元素添加到清单中