TL; DR
现在已实现为插件
const url = "https://flutter.io";if (await canLaunch(url)) launch(url);else // can't launch url, there is some error
完整示例:
import 'package:flutter/material.dart';import 'package:url_launcher/url_launcher.dart';void main() { runApp(new Scaffold( body: new Center( child: new RaisedButton( onPressed: _launchURL, child: new Text('Show Flutter homepage'), ), ), ));}_launchURL() async { const url = 'https://flutter.io'; if (await canLaunch(url)) { await launch(url); } else { throw 'Could not launch $url'; }}
在pubspec.yaml中
特殊的角色:dependencies: url_launcher: ^5.4.2
如果该
url值包含网址中现在允许的空格或其他值,请使用
Uri.enpreFull(urlString)或
Uri.enpreComponent(urlString),而是传递结果值。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)