这是我的代码,可以在Android上正常运行,并在浏览器上打开URl:
_launchURL(url) async {
if (await canLaunch(url)) {
await launch(url);
} else {
throw 'Could not launch $url';
}
}
但是对于IOS,我会收到此错误:
2020-10-22 10:23:23.896883+0300 Runner[805:312838] -canOpenURL: failed for URL: "(null)" - error: "Invalid input URL"
2020-10-22 10:23:23.899096+0300 Runner[805:313046] [VERBOSE-2:ui_dart_state.cc(177)] Unhandled Exception: Could not launch https://manager.alkadhum-col.edu.iq/storage/test.pdf
我不明白为什么说failed for URL: "(null)"
,而所打印的URL显然不是空的,程序没有传递canLaunch()
函数。
我也尝试了launch(url)
而不使用canLaunch(url)
的情况,但出现此错误:
'NSInvalidArgumentException', reason: 'The specified URL has an unsupported scheme. Only HTTP and HTTPS URLs are supported.'