diff --git a/example/lib/main.dart b/example/lib/main.dart index 99ced1a..e7ed64d 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -42,33 +42,30 @@ class Home extends StatefulWidget { } class _HomeState extends State { - late final StreamSubscription _auth = - Weibo.instance.authResp().listen(_listenAuth); - late final StreamSubscription _share = - Weibo.instance.shareMsgResp().listen(_listenShareMsg); + late final StreamSubscription _respSubs = + Weibo.instance.respStream().listen(_listenResp); - WeiboAuthResp? _authResp; + AuthResp? _authResp; @override void initState() { super.initState(); } - void _listenAuth(WeiboAuthResp resp) { - _authResp = resp; - final String content = 'auth: ${resp.errorCode}'; - _showTips('登录', content); - } - - void _listenShareMsg(WeiboSdkResp resp) { - final String content = 'share: ${resp.errorCode}'; - _showTips('分享', content); + void _listenResp(BaseResp resp) { + if (resp is AuthResp) { + _authResp = resp; + final String content = 'auth: ${resp.errorCode}'; + _showTips('登录', content); + } else if (resp is ShareMsgResp) { + final String content = 'share: ${resp.errorCode}'; + _showTips('分享', content); + } } @override void dispose() { - _auth.cancel(); - _share.cancel(); + _respSubs.cancel(); super.dispose(); } diff --git a/example/lib/model/weibo_api_resp.dart b/example/lib/model/weibo_api_resp.dart index d456019..17f1ee2 100644 --- a/example/lib/model/weibo_api_resp.dart +++ b/example/lib/model/weibo_api_resp.dart @@ -82,4 +82,3 @@ class WeiboUserInfoResp extends WeiboApiResp { Map toJson() => _$WeiboUserInfoRespToJson(this); } - diff --git a/example/lib/weibo.dart b/example/lib/weibo.dart index 455055a..ebdee1a 100644 --- a/example/lib/weibo.dart +++ b/example/lib/weibo.dart @@ -6,7 +6,6 @@ import 'package:weibo_kit/weibo_kit.dart'; import 'package:weibo_kit_example/model/weibo_api_resp.dart'; extension ApiWeibo on Weibo { - /// 用户信息 Future getUserInfo({ required String appkey,