Closed ChiGlobal closed 4 years ago
@Akchy hello please can you help🙏🏼
@ChiGlobal Its showing the error because the username is having null value. I cant debug it as it is. Can you tell me how you got it?
@Akchy ok so, because of the nature of my project I split your code into two sides... one for the audience and one for the host. This might be the reason why it's having this problem, here is the code below:
this is for the host: help.txt
and this is for the audience: audience.txt
the audience have their own separate project from the host
The error is from Host file, Hope you have a firebase account with cloud firestore database, because the data to store in userName is from either sharedpref or cloud firestore.
Can you check either of those? (try debugging the results each produce)
@Akchy so this is what at am getting:
Hey, the screenshots are relevant. I was asking about the variable "userName"
@Akchy ok, will check it
here it is:
@ChiGlobal as mentioned before add print statements after you recieve value from shared pref or Firebase with userName. That's the error you want to know
@Akchy Ok, just found out that I was using a different user class from the one in your project... Please can you tell me how to add the agora SDK with my user class
class User {
String key;
String email;
String userId;
String displayName;
String userName;
String webSite;
String profilePic;
String contact;
String bio;
String location;
String dob;
String createdAt;
int channelId;
bool me;
bool isVerified;
int followers;
int following;
String fcmToken;
List<String> followersList;
List<String> followingList;
User({
this.email,
this.userId,
this.displayName,
this.profilePic,
this.key,
this.contact,
this.bio,
this.channelId,
this.me,
this.dob,
this.location,
this.createdAt,
this.userName,
this.followers,
this.following,
this.webSite,
this.isVerified,
this.fcmToken,
this.followersList,
});
User.fromJson(Map<dynamic, dynamic> map) {
if (map == null) {
return;
}
if (followersList == null) {
followersList = [];
}
email = map['email'];
userId = map['userId'];
displayName = map['displayName'];
profilePic = map['profilePic'];
key = map['key'];
dob = map['dob'];
bio = map['bio'];
location = map['location'];
contact = map['contact'];
createdAt = map['createdAt'];
followers = map['followers'];
following = map['following'];
userName = map['userName'];
webSite = map['webSite'];
fcmToken = map['fcmToken'];
isVerified = map['isVerified'] ?? false;
if (map['followerList'] != null) {
followersList = List<String>();
map['followerList'].forEach((value) {
followersList.add(value);
});
}
followers = followersList != null ? followersList.length : null;
if (map['followingList'] != null) {
followingList = List<String>();
map['followingList'].forEach((value) {
followingList.add(value);
});
}
following = followingList != null ? followingList.length : null;
}
toJson() {
return {
'key': key,
"userId": userId,
"email": email,
'displayName': displayName,
// ignore: equal_keys_in_map
'userId': userId,
'profilePic': profilePic,
'contact': contact,
'dob': dob,
'bio': bio,
'location': location,
'createdAt': createdAt,
'followers': followersList != null ? followersList.length : null,
'following': followingList != null ? followingList.length : null,
'userName': userName,
'webSite': webSite,
'isVerified': isVerified ?? false,
'fcmToken': fcmToken,
'followerList': followersList,
'followingList': followingList
};
}
User copyWith({
String email,
String userId,
String displayName,
String profilePic,
String key,
String contact,
bio,
String dob,
String location,
String createdAt,
String userName,
int followers,
int following,
String webSite,
bool isVerified,
String fcmToken,
List<String> followingList,
}) {
return User(
email: email ?? this.email,
bio: bio ?? this.bio,
contact: contact ?? this.contact,
createdAt: createdAt ?? this.createdAt,
displayName: displayName ?? this.displayName,
dob: dob ?? this.dob,
followers: followersList != null ? followersList.length : null,
following: following ?? this.following,
isVerified: isVerified ?? this.isVerified,
key: key ?? this.key,
location: location ?? this.location,
profilePic: profilePic ?? this.profilePic,
userId: userId ?? this.userId,
userName: userName ?? this.userName,
webSite: webSite ?? this.webSite,
fcmToken: fcmToken ?? this.fcmToken,
followersList: followersList ?? this.followersList,
);
}
String getFollower() {
return '${this.followers ?? 0}';
}
String getFollowing() {
return '${this.following ?? 0}';
}
}
Above is my user class
@Akchy Hello, are you there?
Please help, just got his error message