url_launcher: ^6.1.12下载最新版本的
import 'package:url_launcher/url_launcher.dart';
class wxOpen extends StatelessWidget {
void openWeChatAuthorization() async {
final String wechatAuthUrl = 'weixin://'; // 微信授权的URL,可以根据需求调整
if (await canLaunch(wechatAuthUrl)) {
await launch(wechatAuthUrl);
} else {
print('无法打开微信');
}
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: Text('打开微信'),
),
body: Center(
child: ElevatedButton(
onPressed: openWeChatAuthorization,
child: Text('打开微信'),
),
),
),
);
}
}
flutter app打开微信
于 2023-11-08 11:16:34 首次发布