Flutter桌面软件调用外部浏览器

发布于 1周前 作者 phonegap100 最后一次编辑是 5天前 来自 分享

Flutter桌面软件调用外部浏览器我们同样可以使用 url_launcher

地址:https://pub.dev/packages/url_launcher

Android iOS Linux macOS Web Windows
Support SDK 16+ 11.0+ Any 10.11+ Any Windows 10+

Flutter桌面软件调用外部浏览器插件 url_launcher的使用

1、安装应用

dependencies:
  url_launcher: ^6.1.10
import 'package:url_launcher/url_launcher.dart';

2、引入使用

ElevatedButton(
              child: const Text('打开外部浏览器'),
              onPressed: () async {
                final Uri url = Uri.parse('https://www.itying.com');
                if (await canLaunchUrl(url)) {
                  await launchUrl(url);
                } else {
                  throw 'Could not launch $url';
                }
              },
 ),

更多关于Flutter桌面软件调用外部浏览器的实战系列教程也可以访问 https://www.itying.com/category-92-b0.html

回到顶部
AI 助手
你好,我是IT营的 AI 助手
您可以尝试点击下方的快捷入口开启体验!