【发布时间】:2022-06-27 18:45:06
【问题描述】:
为什么即使链接存在,它也会抛出错误并给我链接是空的? 当我单独使用启动(url)时,链接打开没有任何问题
String StateUrl = 'View App' ;
var url = 'https://www.youtube.com/watch?v=-k0IXjCHObw' ;
body: Column(
children: [
Text(StateUrl),
Center(
child: ElevatedButton.icon(
onPressed: () async{
try {
await canLaunch(url) ?
await launch(url):
throw 'Error';
} catch(e){
setState(() {
StateUrl = e.toString() ;
});
}
},
icon: const Icon(FontAwesomeIcons.link),
label: const Text('View Url')
),
),
],
),
执行热重载
D/EGL_emulation(17669): app_time_stats: avg=17852.65ms min=658.78ms max=35046.52ms count=2 I/UrlLauncher(17669): 组件名 https://www.youtube.com/watch?v=-k0IXjCHObw 为空 D/EGL_emulation(17669): app_time_stats: avg=8279.72ms min=8279.72ms max=8279.72ms 计数=1
【问题讨论】: