Skip to content

Commit a7958d4

Browse files
committed
🐛 (fix) like count showing null value.
1. 🐛 Fixed null value in few tweets. 2. 🐛 Fixed null names in chat list after tagging any user in compose tweet.
1 parent 0cf0a0a commit a7958d4

File tree

4 files changed

+18
-10
lines changed

4 files changed

+18
-10
lines changed

lib/model/feedModel.dart

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class FeedModel {
5454
userId = map['userId'];
5555
// name = map['name'];
5656
// profilePic = map['profilePic'];
57-
likeCount = map['likeCount'];
57+
likeCount = map['likeCount'] ?? 0;
5858
commentCount = map['commentCount'];
5959
retweetCount = map["retweetCount"] ?? 0;
6060
imagePath = map['imagePath'];
@@ -72,12 +72,17 @@ class FeedModel {
7272
}
7373
if (map["likeList"] != null) {
7474
likeList = List<String>();
75-
final list = map['likeList'];
76-
if (list is List) {
77-
map['likeList'].forEach((value) {
78-
likeList.add(value);
79-
});
80-
likeCount = likeList.length;
75+
try {
76+
final list = map['likeList'];
77+
if (list is List) {
78+
map['likeList'].forEach((value) {
79+
likeList.add(value);
80+
});
81+
likeCount = likeList.length ?? 0;
82+
}
83+
} catch (e) {
84+
likeCount = 0;
85+
likeList = [];
8186
}
8287
} else {
8388
likeList = [];

lib/page/feed/composeTweet/composeTweet.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,7 @@ class _UserList extends StatelessWidget {
567567
onUserSelected: (user) {
568568
textEditingController.text =
569569
Provider.of<ComposeTweetState>(context)
570-
.getDescription(user.userName);
570+
.getDescription(user.userName) + " ";
571571
textEditingController.selection = TextSelection.collapsed(
572572
offset: textEditingController.text.length);
573573
Provider.of<ComposeTweetState>(context).onUserSelected();

lib/page/message/chatListPage.dart

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ class _ChatListPageState extends State<ChatListPage> {
4646
),
4747
);
4848
} else {
49+
if(searchState.userList.isEmpty){
50+
searchState.resetFilterList();
51+
}
4952
return ListView.separated(
5053
physics: BouncingScrollPhysics(),
5154
itemCount: state.chatUserList.length,
@@ -100,7 +103,7 @@ class _ChatListPageState extends State<ChatListPage> {
100103
),
101104
),
102105
title: TitleText(
103-
model.displayName,
106+
model.displayName ?? "NA",
104107
fontSize: 16,
105108
fontWeight: FontWeight.w800,
106109
overflow: TextOverflow.ellipsis,

lib/widgets/tweet/widgets/tweetIconsRow.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ class TweetIconsRow extends StatelessWidget {
143143
}
144144

145145
Widget _likeCommentWidget(BuildContext context) {
146-
bool isLikeAvailable = model.likeCount > 0;
146+
bool isLikeAvailable = model.likeCount != null ? model.likeCount > 0 : false;
147147
bool isRetweetAvailable = model.retweetCount > 0;
148148
bool isLikeRetweetAvailable = isRetweetAvailable || isLikeAvailable;
149149
return Column(

0 commit comments

Comments
 (0)