change some expressions to IIFEs

This commit is contained in:
krawieck 2020-09-01 14:17:56 +02:00
parent 1c9848dced
commit f44c0f60a5
1 changed files with 26 additions and 23 deletions

View File

@ -25,30 +25,33 @@ class Comment extends StatelessWidget {
var comment = commentTree.comment; var comment = commentTree.comment;
// decide which username to use // decide which username to use
var username; final username = () {
if (comment.creatorPreferredUsername != null && if (comment.creatorPreferredUsername != null &&
comment.creatorPreferredUsername != '') { comment.creatorPreferredUsername != '') {
username = comment.creatorPreferredUsername; return comment.creatorPreferredUsername;
} else { } else {
username = '@${comment.creatorName}'; return '@${comment.creatorName}';
} }
}();
final body = () {
if (comment.deleted) {
return Flexible(
child: Text(
'comment deleted by creator',
style: TextStyle(fontStyle: FontStyle.italic),
));
} else if (comment.removed) {
return Flexible(
child: Text(
'comment deleted by moderator',
style: TextStyle(fontStyle: FontStyle.italic),
));
} else {
return Flexible(child: MarkdownText(commentTree.comment.content));
}
}();
var body;
if (comment.deleted) {
body = Flexible(
child: Text(
'comment deleted by creator',
style: TextStyle(fontStyle: FontStyle.italic),
));
} else if (comment.removed) {
body = Flexible(
child: Text(
'comment deleted by moderator',
style: TextStyle(fontStyle: FontStyle.italic),
));
} else {
body = Flexible(child: MarkdownText(commentTree.comment.content));
}
return Column( return Column(
children: [ children: [
Container( Container(