mirror of
https://github.com/RxReader/tencent_kit.git
synced 2025-05-22 17:55:59 +08:00
feature 5.0.0
This commit is contained in:
@ -6,32 +6,31 @@ part of 'tencent_api_resp.dart';
|
|||||||
// JsonSerializableGenerator
|
// JsonSerializableGenerator
|
||||||
// **************************************************************************
|
// **************************************************************************
|
||||||
|
|
||||||
TencentUserInfoResp _$TencentUserInfoRespFromJson(Map<String, dynamic> json) {
|
TencentUserInfoResp _$TencentUserInfoRespFromJson(Map<String, dynamic> json) =>
|
||||||
return TencentUserInfoResp(
|
TencentUserInfoResp(
|
||||||
ret: json['ret'] as int? ?? 0,
|
ret: json['ret'] as int? ?? 0,
|
||||||
msg: json['msg'] as String?,
|
msg: json['msg'] as String?,
|
||||||
isLost: json['is_lost'] as int?,
|
isLost: json['is_lost'] as int?,
|
||||||
nickname: json['nickname'] as String?,
|
nickname: json['nickname'] as String?,
|
||||||
gender: json['gender'] as String?,
|
gender: json['gender'] as String?,
|
||||||
genderType: json['gender_type'] as int?,
|
genderType: json['gender_type'] as int?,
|
||||||
province: json['province'] as String?,
|
province: json['province'] as String?,
|
||||||
city: json['city'] as String?,
|
city: json['city'] as String?,
|
||||||
year: json['year'] as String?,
|
year: json['year'] as String?,
|
||||||
constellation: json['constellation'] as String?,
|
constellation: json['constellation'] as String?,
|
||||||
figureurl: json['figureurl'] as String?,
|
figureurl: json['figureurl'] as String?,
|
||||||
figureurl1: json['figureurl_1'] as String?,
|
figureurl1: json['figureurl_1'] as String?,
|
||||||
figureurl2: json['figureurl_2'] as String?,
|
figureurl2: json['figureurl_2'] as String?,
|
||||||
figureurlQq: json['figureurl_qq'] as String?,
|
figureurlQq: json['figureurl_qq'] as String?,
|
||||||
figureurlQq1: json['figureurl_qq_1'] as String?,
|
figureurlQq1: json['figureurl_qq_1'] as String?,
|
||||||
figureurlQq2: json['figureurl_qq_2'] as String?,
|
figureurlQq2: json['figureurl_qq_2'] as String?,
|
||||||
figureurlType: json['figureurl_type'] as String?,
|
figureurlType: json['figureurl_type'] as String?,
|
||||||
isYellowVip: json['is_yellow_vip'] as String?,
|
isYellowVip: json['is_yellow_vip'] as String?,
|
||||||
vip: json['vip'] as String?,
|
vip: json['vip'] as String?,
|
||||||
yellowVipLevel: json['yellow_vip_level'] as String?,
|
yellowVipLevel: json['yellow_vip_level'] as String?,
|
||||||
level: json['level'] as String?,
|
level: json['level'] as String?,
|
||||||
isYellowYearVip: json['is_yellow_year_vip'] as String?,
|
isYellowYearVip: json['is_yellow_year_vip'] as String?,
|
||||||
);
|
);
|
||||||
}
|
|
||||||
|
|
||||||
Map<String, dynamic> _$TencentUserInfoRespToJson(
|
Map<String, dynamic> _$TencentUserInfoRespToJson(
|
||||||
TencentUserInfoResp instance) =>
|
TencentUserInfoResp instance) =>
|
||||||
|
@ -6,15 +6,14 @@ part of 'tencent_unionid_resp.dart';
|
|||||||
// JsonSerializableGenerator
|
// JsonSerializableGenerator
|
||||||
// **************************************************************************
|
// **************************************************************************
|
||||||
|
|
||||||
TencentUnionidResp _$TencentUnionidRespFromJson(Map<String, dynamic> json) {
|
TencentUnionidResp _$TencentUnionidRespFromJson(Map<String, dynamic> json) =>
|
||||||
return TencentUnionidResp(
|
TencentUnionidResp(
|
||||||
error: json['error'] as int? ?? 0,
|
error: json['error'] as int? ?? 0,
|
||||||
errorDescription: json['error_description'] as String?,
|
errorDescription: json['error_description'] as String?,
|
||||||
clientId: json['client_id'] as String?,
|
clientId: json['client_id'] as String?,
|
||||||
openid: json['openid'] as String?,
|
openid: json['openid'] as String?,
|
||||||
unionid: json['unionid'] as String?,
|
unionid: json['unionid'] as String?,
|
||||||
);
|
);
|
||||||
}
|
|
||||||
|
|
||||||
Map<String, dynamic> _$TencentUnionidRespToJson(TencentUnionidResp instance) =>
|
Map<String, dynamic> _$TencentUnionidRespToJson(TencentUnionidResp instance) =>
|
||||||
<String, dynamic>{
|
<String, dynamic>{
|
||||||
|
@ -40,9 +40,9 @@ class Home extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _HomeState extends State<Home> {
|
class _HomeState extends State<Home> {
|
||||||
late final StreamSubscription<BaseResp> _respSubs;
|
late final StreamSubscription<TencentResp> _respSubs;
|
||||||
|
|
||||||
LoginResp? _loginResp;
|
TencentLoginResp? _loginResp;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
@ -50,12 +50,12 @@ class _HomeState extends State<Home> {
|
|||||||
_respSubs = TencentKitPlatform.instance.respStream().listen(_listenLogin);
|
_respSubs = TencentKitPlatform.instance.respStream().listen(_listenLogin);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _listenLogin(BaseResp resp) {
|
void _listenLogin(TencentResp resp) {
|
||||||
if (resp is LoginResp) {
|
if (resp is TencentLoginResp) {
|
||||||
_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) {
|
} else if (resp is TencentShareMsgResp) {
|
||||||
final String content = 'share: ${resp.ret} - ${resp.msg}';
|
final String content = 'share: ${resp.ret} - ${resp.msg}';
|
||||||
_showTips('分享', content);
|
_showTips('分享', content);
|
||||||
}
|
}
|
||||||
|
@ -4,8 +4,8 @@ import 'package:json_annotation/json_annotation.dart';
|
|||||||
|
|
||||||
part 'resp.g.dart';
|
part 'resp.g.dart';
|
||||||
|
|
||||||
abstract class BaseResp {
|
abstract class TencentResp {
|
||||||
const BaseResp({
|
const TencentResp({
|
||||||
required this.ret,
|
required this.ret,
|
||||||
this.msg,
|
this.msg,
|
||||||
});
|
});
|
||||||
@ -41,8 +41,8 @@ abstract class BaseResp {
|
|||||||
explicitToJson: true,
|
explicitToJson: true,
|
||||||
fieldRename: FieldRename.snake,
|
fieldRename: FieldRename.snake,
|
||||||
)
|
)
|
||||||
class LoginResp extends BaseResp {
|
class TencentLoginResp extends TencentResp {
|
||||||
const LoginResp({
|
const TencentLoginResp({
|
||||||
required super.ret,
|
required super.ret,
|
||||||
super.msg,
|
super.msg,
|
||||||
this.openid,
|
this.openid,
|
||||||
@ -51,8 +51,8 @@ class LoginResp extends BaseResp {
|
|||||||
this.createAt,
|
this.createAt,
|
||||||
});
|
});
|
||||||
|
|
||||||
factory LoginResp.fromJson(Map<String, dynamic> json) =>
|
factory TencentLoginResp.fromJson(Map<String, dynamic> json) =>
|
||||||
_$LoginRespFromJson(json);
|
_$TencentLoginRespFromJson(json);
|
||||||
|
|
||||||
final String? openid;
|
final String? openid;
|
||||||
final String? accessToken;
|
final String? accessToken;
|
||||||
@ -64,22 +64,22 @@ class LoginResp extends BaseResp {
|
|||||||
: null;
|
: null;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Map<String, dynamic> toJson() => _$LoginRespToJson(this);
|
Map<String, dynamic> toJson() => _$TencentLoginRespToJson(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@JsonSerializable(
|
@JsonSerializable(
|
||||||
explicitToJson: true,
|
explicitToJson: true,
|
||||||
fieldRename: FieldRename.snake,
|
fieldRename: FieldRename.snake,
|
||||||
)
|
)
|
||||||
class ShareMsgResp extends BaseResp {
|
class TencentShareMsgResp extends TencentResp {
|
||||||
const ShareMsgResp({
|
const TencentShareMsgResp({
|
||||||
required super.ret,
|
required super.ret,
|
||||||
super.msg,
|
super.msg,
|
||||||
});
|
});
|
||||||
|
|
||||||
factory ShareMsgResp.fromJson(Map<String, dynamic> json) =>
|
factory TencentShareMsgResp.fromJson(Map<String, dynamic> json) =>
|
||||||
_$ShareMsgRespFromJson(json);
|
_$TencentShareMsgRespFromJson(json);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Map<String, dynamic> toJson() => _$ShareMsgRespToJson(this);
|
Map<String, dynamic> toJson() => _$TencentShareMsgRespToJson(this);
|
||||||
}
|
}
|
||||||
|
@ -6,18 +6,18 @@ part of 'resp.dart';
|
|||||||
// JsonSerializableGenerator
|
// JsonSerializableGenerator
|
||||||
// **************************************************************************
|
// **************************************************************************
|
||||||
|
|
||||||
LoginResp _$LoginRespFromJson(Map<String, dynamic> json) {
|
TencentLoginResp _$TencentLoginRespFromJson(Map<String, dynamic> json) =>
|
||||||
return LoginResp(
|
TencentLoginResp(
|
||||||
ret: json['ret'] as int? ?? 0,
|
ret: json['ret'] as int? ?? 0,
|
||||||
msg: json['msg'] as String?,
|
msg: json['msg'] as String?,
|
||||||
openid: json['openid'] as String?,
|
openid: json['openid'] as String?,
|
||||||
accessToken: json['access_token'] as String?,
|
accessToken: json['access_token'] as String?,
|
||||||
expiresIn: json['expires_in'] as int?,
|
expiresIn: json['expires_in'] as int?,
|
||||||
createAt: json['create_at'] as int?,
|
createAt: json['create_at'] as int?,
|
||||||
);
|
);
|
||||||
}
|
|
||||||
|
|
||||||
Map<String, dynamic> _$LoginRespToJson(LoginResp instance) => <String, dynamic>{
|
Map<String, dynamic> _$TencentLoginRespToJson(TencentLoginResp instance) =>
|
||||||
|
<String, dynamic>{
|
||||||
'ret': instance.ret,
|
'ret': instance.ret,
|
||||||
'msg': instance.msg,
|
'msg': instance.msg,
|
||||||
'openid': instance.openid,
|
'openid': instance.openid,
|
||||||
@ -26,14 +26,14 @@ Map<String, dynamic> _$LoginRespToJson(LoginResp instance) => <String, dynamic>{
|
|||||||
'create_at': instance.createAt,
|
'create_at': instance.createAt,
|
||||||
};
|
};
|
||||||
|
|
||||||
ShareMsgResp _$ShareMsgRespFromJson(Map<String, dynamic> json) {
|
TencentShareMsgResp _$TencentShareMsgRespFromJson(Map<String, dynamic> json) =>
|
||||||
return ShareMsgResp(
|
TencentShareMsgResp(
|
||||||
ret: json['ret'] as int? ?? 0,
|
ret: json['ret'] as int? ?? 0,
|
||||||
msg: json['msg'] as String?,
|
msg: json['msg'] as String?,
|
||||||
);
|
);
|
||||||
}
|
|
||||||
|
|
||||||
Map<String, dynamic> _$ShareMsgRespToJson(ShareMsgResp instance) =>
|
Map<String, dynamic> _$TencentShareMsgRespToJson(
|
||||||
|
TencentShareMsgResp instance) =>
|
||||||
<String, dynamic>{
|
<String, dynamic>{
|
||||||
'ret': instance.ret,
|
'ret': instance.ret,
|
||||||
'msg': instance.msg,
|
'msg': instance.msg,
|
||||||
|
@ -14,17 +14,17 @@ class MethodChannelTencentKit extends TencentKitPlatform {
|
|||||||
const MethodChannel('v7lin.github.io/tencent_kit')
|
const MethodChannel('v7lin.github.io/tencent_kit')
|
||||||
..setMethodCallHandler(_handleMethod);
|
..setMethodCallHandler(_handleMethod);
|
||||||
|
|
||||||
final StreamController<BaseResp> _respStreamController =
|
final StreamController<TencentResp> _respStreamController =
|
||||||
StreamController<BaseResp>.broadcast();
|
StreamController<TencentResp>.broadcast();
|
||||||
|
|
||||||
Future<dynamic> _handleMethod(MethodCall call) async {
|
Future<dynamic> _handleMethod(MethodCall call) async {
|
||||||
switch (call.method) {
|
switch (call.method) {
|
||||||
case 'onLoginResp':
|
case 'onLoginResp':
|
||||||
_respStreamController.add(LoginResp.fromJson(
|
_respStreamController.add(TencentLoginResp.fromJson(
|
||||||
(call.arguments as Map<dynamic, dynamic>).cast<String, dynamic>()));
|
(call.arguments as Map<dynamic, dynamic>).cast<String, dynamic>()));
|
||||||
break;
|
break;
|
||||||
case 'onShareResp':
|
case 'onShareResp':
|
||||||
_respStreamController.add(ShareMsgResp.fromJson(
|
_respStreamController.add(TencentShareMsgResp.fromJson(
|
||||||
(call.arguments as Map<dynamic, dynamic>).cast<String, dynamic>()));
|
(call.arguments as Map<dynamic, dynamic>).cast<String, dynamic>()));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -59,7 +59,7 @@ class MethodChannelTencentKit extends TencentKitPlatform {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Stream<BaseResp> respStream() {
|
Stream<TencentResp> respStream() {
|
||||||
return _respStreamController.stream;
|
return _respStreamController.stream;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ abstract class TencentKitPlatform extends PlatformInterface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
Stream<BaseResp> respStream() {
|
Stream<TencentResp> respStream() {
|
||||||
throw UnimplementedError('respStream() has not been implemented.');
|
throw UnimplementedError('respStream() has not been implemented.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ class MockTencentKitPlatform
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Stream<BaseResp> respStream() {
|
Stream<TencentResp> respStream() {
|
||||||
throw UnimplementedError();
|
throw UnimplementedError();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user