[core] Remove Blank in Item Preview Description (#86)

This commit removes all blank lines in the item preview description, so
that we do not render a blank line as the last line. This was done to
improve the style of the item previews, which looked ugly when the last
line was a blank line.
This commit is contained in:
Rico Berger
2023-11-29 21:47:53 +01:00
committed by GitHub
parent 04ef618295
commit abd3c24f68

View File

@@ -81,6 +81,10 @@ class ItemDescription extends StatelessWidget {
}
/// [_buildPlain] renders the provided [content] as plain text.
///
/// To not have some trailing newlines, the [content] is trimmed and splitted
/// on newline characters, so that we can filter out empty lines, before the
/// the content is rendered.
Widget _buildPlain(String content) {
if (content == '') {
return Container();
@@ -91,7 +95,7 @@ class ItemDescription extends StatelessWidget {
bottom: Constants.spacingExtraSmall,
),
child: Text(
content.trim(),
content.trim().split('\n').where((line) => line != '').join('\n'),
maxLines: 5,
style: const TextStyle(
overflow: TextOverflow.ellipsis,