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
+8 -4
View File
@@ -269,14 +269,18 @@ class ChannelPreview extends StatelessWidget {
var textList = text.split(' ');
List<TextSpan> resList = [];
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(
text: '$e ',
style: mentionsTextStyle,
));
} else if (attachments
.where((e) => e.title != null)
.any((element) => element.title == e)) {
} else if (attachments != null &&
attachments.isNotEmpty &&
attachments
.where((e) => e.title != null)
.any((element) => element.title == e)) {
resList.add(TextSpan(
text: '$e ',
style: normalTextStyle.copyWith(fontStyle: FontStyle.italic),
+8 -4
View File
@@ -165,14 +165,18 @@ class MessageSearchItem extends StatelessWidget {
var textList = text.split(' ');
List<TextSpan> resList = [];
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(
text: '$e ',
style: mentionsTextStyle,
));
} else if (attachments
.where((e) => e.title != null)
.any((element) => element.title == e)) {
} else if (attachments != null &&
attachments.isNotEmpty &&
attachments
.where((e) => e.title != null)
.any((element) => element.title == e)) {
resList.add(TextSpan(
text: '$e ',
style: normalTextStyle.copyWith(fontStyle: FontStyle.italic),