This commit is contained in:
v7lin 2021-07-31 20:11:51 +08:00
parent d12244f1d3
commit c61a111ef2
3 changed files with 13 additions and 18 deletions

View File

@ -42,33 +42,30 @@ class Home extends StatefulWidget {
}
class _HomeState extends State<Home> {
late final StreamSubscription<WeiboAuthResp> _auth =
Weibo.instance.authResp().listen(_listenAuth);
late final StreamSubscription<WeiboSdkResp> _share =
Weibo.instance.shareMsgResp().listen(_listenShareMsg);
late final StreamSubscription<BaseResp> _respSubs =
Weibo.instance.respStream().listen(_listenResp);
WeiboAuthResp? _authResp;
AuthResp? _authResp;
@override
void initState() {
super.initState();
}
void _listenAuth(WeiboAuthResp resp) {
void _listenResp(BaseResp resp) {
if (resp is AuthResp) {
_authResp = resp;
final String content = 'auth: ${resp.errorCode}';
_showTips('登录', content);
}
void _listenShareMsg(WeiboSdkResp resp) {
} else if (resp is ShareMsgResp) {
final String content = 'share: ${resp.errorCode}';
_showTips('分享', content);
}
}
@override
void dispose() {
_auth.cancel();
_share.cancel();
_respSubs.cancel();
super.dispose();
}

View File

@ -82,4 +82,3 @@ class WeiboUserInfoResp extends WeiboApiResp {
Map<String, dynamic> toJson() => _$WeiboUserInfoRespToJson(this);
}

View File

@ -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<WeiboUserInfoResp> getUserInfo({
required String appkey,