From 2eebcf2a0a15b19b7812e5eed908f4b3821fd4d5 Mon Sep 17 00:00:00 2001 From: v7lin Date: Sat, 31 Jul 2021 16:24:13 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B4=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- example/lib/main.dart | 29 +++++++++++++---------------- example/lib/tencent.dart | 1 - example/pubspec.lock | 2 +- 3 files changed, 14 insertions(+), 18 deletions(-) diff --git a/example/lib/main.dart b/example/lib/main.dart index 384d8ca..d1c2a44 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -33,33 +33,30 @@ class Home extends StatefulWidget { } class _HomeState extends State { - late final StreamSubscription _login = - Tencent.instance.loginResp().listen(_listenLogin); - late final StreamSubscription _share = - Tencent.instance.shareResp().listen(_listenShare); + late final StreamSubscription _respSubs = + Tencent.instance.respStream().listen(_listenLogin); - TencentLoginResp? _loginResp; + LoginResp? _loginResp; @override void initState() { super.initState(); } - void _listenLogin(TencentLoginResp resp) { - _loginResp = resp; - final String content = 'login: ${resp.openid} - ${resp.accessToken}'; - _showTips('登录', content); - } - - void _listenShare(TencentSdkResp resp) { - final String content = 'share: ${resp.ret} - ${resp.msg}'; - _showTips('分享', content); + void _listenLogin(BaseResp resp) { + if (resp is LoginResp) { + _loginResp = resp; + final String content = 'login: ${resp.openid} - ${resp.accessToken}'; + _showTips('登录', content); + } else if (resp is ShareMsgResp) { + final String content = 'share: ${resp.ret} - ${resp.msg}'; + _showTips('分享', content); + } } @override void dispose() { - _login.cancel(); - _share.cancel(); + _respSubs.cancel(); super.dispose(); } diff --git a/example/lib/tencent.dart b/example/lib/tencent.dart index 571cf8a..5afaf92 100644 --- a/example/lib/tencent.dart +++ b/example/lib/tencent.dart @@ -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'; extension MixerTencent on Tencent { - /// 用户信息 /// https://wiki.connect.qq.com/get_user_info Future getUserInfo({ diff --git a/example/pubspec.lock b/example/pubspec.lock index b69a7f4..3172f70 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -288,7 +288,7 @@ packages: path: ".." relative: true source: path - version: "2.1.1" + version: "3.0.0" term_glyph: dependency: transitive description: