I want to have ListTile
widget that sometimes has title
as null, e.g.:
ListTile(
title: item.title.isNotEmpty
? Text(
item.title,
maxLines: 1,
)
: null,
subtitle: Text(
task.text,
maxLines: 3,
overflow: TextOverflow.fade,
),
}
If the title
is null, it stays there as an empty space, which causes entire widget to look ugly.
On the other hand, if the subtitle is null, it nicely collapse.
2
Answers
Yes you can.
You have an error in your code, you closed your ListTitle with this ‘}’, replace it with ‘)’.
Result will be:
You can place the
subtitle
text ontitle
place whentitle
is empty.