This commit is contained in:
v7lin
2021-07-31 16:24:13 +08:00
parent 1fd77f8d59
commit 2eebcf2a0a
3 changed files with 14 additions and 18 deletions

View File

@ -33,33 +33,30 @@ class Home extends StatefulWidget {
} }
class _HomeState extends State<Home> { class _HomeState extends State<Home> {
late final StreamSubscription<TencentLoginResp> _login = late final StreamSubscription<BaseResp> _respSubs =
Tencent.instance.loginResp().listen(_listenLogin); Tencent.instance.respStream().listen(_listenLogin);
late final StreamSubscription<TencentSdkResp> _share =
Tencent.instance.shareResp().listen(_listenShare);
TencentLoginResp? _loginResp; LoginResp? _loginResp;
@override @override
void initState() { void initState() {
super.initState(); super.initState();
} }
void _listenLogin(TencentLoginResp resp) { void _listenLogin(BaseResp resp) {
if (resp is LoginResp) {
_loginResp = resp; _loginResp = resp;
final String content = 'login: ${resp.openid} - ${resp.accessToken}'; final String content = 'login: ${resp.openid} - ${resp.accessToken}';
_showTips('登录', content); _showTips('登录', content);
} } else if (resp is ShareMsgResp) {
void _listenShare(TencentSdkResp resp) {
final String content = 'share: ${resp.ret} - ${resp.msg}'; final String content = 'share: ${resp.ret} - ${resp.msg}';
_showTips('分享', content); _showTips('分享', content);
} }
}
@override @override
void dispose() { void dispose() {
_login.cancel(); _respSubs.cancel();
_share.cancel();
super.dispose(); super.dispose();
} }

View File

@ -7,7 +7,6 @@ import 'package:tencent_kit_example/model/api/tencent_user_info_resp.dart';
import 'package:tencent_kit_example/model/unionid/tencent_unionid_resp.dart'; import 'package:tencent_kit_example/model/unionid/tencent_unionid_resp.dart';
extension MixerTencent on Tencent { extension MixerTencent on Tencent {
/// 用户信息 /// 用户信息
/// https://wiki.connect.qq.com/get_user_info /// https://wiki.connect.qq.com/get_user_info
Future<TencentUserInfoResp> getUserInfo({ Future<TencentUserInfoResp> getUserInfo({

View File

@ -288,7 +288,7 @@ packages:
path: ".." path: ".."
relative: true relative: true
source: path source: path
version: "2.1.1" version: "3.0.0"
term_glyph: term_glyph:
dependency: transitive dependency: transitive
description: description: