Change if with 2 `Text`s to 1 `Text` with ternary inside
This commit is contained in:
parent
91aada67e9
commit
fcafde2d0f
|
@ -348,17 +348,14 @@ class PostWidget extends StatelessWidget {
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
Icon(Icons.comment),
|
Icon(Icons.comment),
|
||||||
if (post.numberOfComments == 1)
|
Expanded(
|
||||||
Text(' 1 comment')
|
flex: 999,
|
||||||
else
|
child: Text(
|
||||||
Expanded(
|
''' ${NumberFormat.compact().format(post.numberOfComments)} comment${post.numberOfComments == 1 ? '' : 's'}''',
|
||||||
flex: 999,
|
overflow: TextOverflow.fade,
|
||||||
child: Text(
|
softWrap: false,
|
||||||
''' ${NumberFormat.compact().format(post.numberOfComments)} comments''',
|
|
||||||
overflow: TextOverflow.fade,
|
|
||||||
softWrap: false,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
|
),
|
||||||
Spacer(),
|
Spacer(),
|
||||||
IconButton(
|
IconButton(
|
||||||
icon: Icon(Icons.share),
|
icon: Icon(Icons.share),
|
||||||
|
@ -370,7 +367,7 @@ class PostWidget extends StatelessWidget {
|
||||||
: Icon(Icons.bookmark_border),
|
: Icon(Icons.bookmark_border),
|
||||||
onPressed: _savePost),
|
onPressed: _savePost),
|
||||||
IconButton(icon: Icon(Icons.arrow_upward), onPressed: _upvotePost),
|
IconButton(icon: Icon(Icons.arrow_upward), onPressed: _upvotePost),
|
||||||
Text(post.score.toString()),
|
Text(NumberFormat.compact().format(post.score)),
|
||||||
IconButton(
|
IconButton(
|
||||||
icon: Icon(Icons.arrow_downward), onPressed: _downvotePost),
|
icon: Icon(Icons.arrow_downward), onPressed: _downvotePost),
|
||||||
],
|
],
|
||||||
|
|
Loading…
Reference in New Issue