整理
This commit is contained in:
parent
d12244f1d3
commit
c61a111ef2
@ -42,33 +42,30 @@ class Home extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _HomeState extends State<Home> {
|
class _HomeState extends State<Home> {
|
||||||
late final StreamSubscription<WeiboAuthResp> _auth =
|
late final StreamSubscription<BaseResp> _respSubs =
|
||||||
Weibo.instance.authResp().listen(_listenAuth);
|
Weibo.instance.respStream().listen(_listenResp);
|
||||||
late final StreamSubscription<WeiboSdkResp> _share =
|
|
||||||
Weibo.instance.shareMsgResp().listen(_listenShareMsg);
|
|
||||||
|
|
||||||
WeiboAuthResp? _authResp;
|
AuthResp? _authResp;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
}
|
}
|
||||||
|
|
||||||
void _listenAuth(WeiboAuthResp resp) {
|
void _listenResp(BaseResp resp) {
|
||||||
_authResp = resp;
|
if (resp is AuthResp) {
|
||||||
final String content = 'auth: ${resp.errorCode}';
|
_authResp = resp;
|
||||||
_showTips('登录', content);
|
final String content = 'auth: ${resp.errorCode}';
|
||||||
}
|
_showTips('登录', content);
|
||||||
|
} else if (resp is ShareMsgResp) {
|
||||||
void _listenShareMsg(WeiboSdkResp resp) {
|
final String content = 'share: ${resp.errorCode}';
|
||||||
final String content = 'share: ${resp.errorCode}';
|
_showTips('分享', content);
|
||||||
_showTips('分享', content);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
_auth.cancel();
|
_respSubs.cancel();
|
||||||
_share.cancel();
|
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,4 +82,3 @@ class WeiboUserInfoResp extends WeiboApiResp {
|
|||||||
|
|
||||||
Map<String, dynamic> toJson() => _$WeiboUserInfoRespToJson(this);
|
Map<String, dynamic> toJson() => _$WeiboUserInfoRespToJson(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,7 +6,6 @@ import 'package:weibo_kit/weibo_kit.dart';
|
|||||||
import 'package:weibo_kit_example/model/weibo_api_resp.dart';
|
import 'package:weibo_kit_example/model/weibo_api_resp.dart';
|
||||||
|
|
||||||
extension ApiWeibo on Weibo {
|
extension ApiWeibo on Weibo {
|
||||||
|
|
||||||
/// 用户信息
|
/// 用户信息
|
||||||
Future<WeiboUserInfoResp> getUserInfo({
|
Future<WeiboUserInfoResp> getUserInfo({
|
||||||
required String appkey,
|
required String appkey,
|
||||||
|
Loading…
Reference in New Issue
Block a user