fix: fixed null sometimes popping up

This commit is contained in:
Deven Joshi
2021-01-06 17:00:56 +05:30
parent a8c60a8482
commit 1927a632e0
2 changed files with 16 additions and 8 deletions
+6 -2
View File
@@ -269,12 +269,16 @@ class ChannelPreview extends StatelessWidget {
var textList = text.split(' '); var textList = text.split(' ');
List<TextSpan> resList = []; List<TextSpan> resList = [];
for (var e in textList) { for (var e in textList) {
if (mentions.any((element) => '@${element.name}' == e)) { if (mentions != null &&
mentions.isNotEmpty &&
mentions.any((element) => '@${element.name}' == e)) {
resList.add(TextSpan( resList.add(TextSpan(
text: '$e ', text: '$e ',
style: mentionsTextStyle, style: mentionsTextStyle,
)); ));
} else if (attachments } else if (attachments != null &&
attachments.isNotEmpty &&
attachments
.where((e) => e.title != null) .where((e) => e.title != null)
.any((element) => element.title == e)) { .any((element) => element.title == e)) {
resList.add(TextSpan( resList.add(TextSpan(
+6 -2
View File
@@ -165,12 +165,16 @@ class MessageSearchItem extends StatelessWidget {
var textList = text.split(' '); var textList = text.split(' ');
List<TextSpan> resList = []; List<TextSpan> resList = [];
for (var e in textList) { for (var e in textList) {
if (mentions.any((element) => '@${element.name}' == e)) { if (mentions != null &&
mentions.isNotEmpty &&
mentions.any((element) => '@${element.name}' == e)) {
resList.add(TextSpan( resList.add(TextSpan(
text: '$e ', text: '$e ',
style: mentionsTextStyle, style: mentionsTextStyle,
)); ));
} else if (attachments } else if (attachments != null &&
attachments.isNotEmpty &&
attachments
.where((e) => e.title != null) .where((e) => e.title != null)
.any((element) => element.title == e)) { .any((element) => element.title == e)) {
resList.add(TextSpan( resList.add(TextSpan(