You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
111 lines
3.0 KiB
111 lines
3.0 KiB
class RtcChannelDetail {
|
|
final String channelId;
|
|
final RtcSeatUserInfo? anchorInfo;
|
|
final RtcSeatUserInfo? maleInfo;
|
|
final RtcSeatUserInfo? femaleInfo;
|
|
|
|
const RtcChannelDetail({
|
|
required this.channelId,
|
|
this.anchorInfo,
|
|
this.maleInfo,
|
|
this.femaleInfo,
|
|
});
|
|
|
|
factory RtcChannelDetail.fromJson(Map<String, dynamic> json) {
|
|
return RtcChannelDetail(
|
|
channelId: json['channelId']?.toString() ?? '',
|
|
anchorInfo: _parseSeatInfo(json['anchorInfo']),
|
|
maleInfo: _parseSeatInfo(json['maleInfo']),
|
|
femaleInfo: _parseSeatInfo(json['femaleInfo']),
|
|
);
|
|
}
|
|
|
|
Map<String, dynamic> toJson() {
|
|
return {
|
|
'channelId': channelId,
|
|
'anchorInfo': anchorInfo?.toJson(),
|
|
'maleInfo': maleInfo?.toJson(),
|
|
'femaleInfo': femaleInfo?.toJson(),
|
|
};
|
|
}
|
|
|
|
static RtcSeatUserInfo? _parseSeatInfo(dynamic value) {
|
|
if (value is Map<String, dynamic>) {
|
|
return RtcSeatUserInfo.fromJson(value);
|
|
}
|
|
return null;
|
|
}
|
|
}
|
|
|
|
class RtcSeatUserInfo {
|
|
final String miId;
|
|
final String userId;
|
|
final String nickName;
|
|
final String profilePhoto;
|
|
final int genderCode;
|
|
final int seatNumber;
|
|
final bool isFriend;
|
|
bool isMicrophoneOn;
|
|
final bool isVideoOn;
|
|
final int? uid;
|
|
|
|
RtcSeatUserInfo({
|
|
required this.miId,
|
|
required this.userId,
|
|
required this.nickName,
|
|
required this.profilePhoto,
|
|
required this.genderCode,
|
|
required this.seatNumber,
|
|
required this.isFriend,
|
|
required this.isMicrophoneOn,
|
|
required this.isVideoOn,
|
|
this.uid,
|
|
});
|
|
|
|
factory RtcSeatUserInfo.fromJson(Map<String, dynamic> json) {
|
|
return RtcSeatUserInfo(
|
|
miId: json['miId']?.toString() ?? '',
|
|
userId: json['userId']?.toString() ?? '',
|
|
nickName: json['nickName']?.toString() ?? '',
|
|
profilePhoto: json['profilePhoto']?.toString() ?? '',
|
|
genderCode: json['genderCode'] is int
|
|
? json['genderCode'] as int
|
|
: int.tryParse(json['genderCode']?.toString() ?? '0') ?? 0,
|
|
seatNumber: json['seatNumber'] is int
|
|
? json['seatNumber'] as int
|
|
: int.tryParse(json['seatNumber']?.toString() ?? '0') ?? 0,
|
|
isFriend: _parseBool(json['isFriend']),
|
|
isMicrophoneOn: _parseBool(json['isMicrophoneOn']),
|
|
isVideoOn: _parseBool(json['isVideoOn']),
|
|
uid: json['uid'] is int
|
|
? json['uid'] as int
|
|
: int.tryParse(json['uid']?.toString() ?? ''),
|
|
);
|
|
}
|
|
|
|
Map<String, dynamic> toJson() {
|
|
return {
|
|
'miId': miId,
|
|
'userId': userId,
|
|
'nickName': nickName,
|
|
'profilePhoto': profilePhoto,
|
|
'genderCode': genderCode,
|
|
'seatNumber': seatNumber,
|
|
'isFriend': isFriend,
|
|
'isMicrophoneOn': isMicrophoneOn,
|
|
'isVideoOn': isVideoOn,
|
|
'uid': uid,
|
|
};
|
|
}
|
|
|
|
static bool _parseBool(dynamic value) {
|
|
if (value is bool) return value;
|
|
if (value is num) return value != 0;
|
|
if (value is String) {
|
|
return value == '1' ||
|
|
value.toLowerCase() == 'true' ||
|
|
value.toLowerCase() == 'yes';
|
|
}
|
|
return false;
|
|
}
|
|
}
|