在 ListTile 的副标题内实现 if 语句

implement if statement inside subtitle in ListTile

有什么方法可以在 ListTile 的副标题内实现 if 语句?我可以将它直接放在小部件中,但不能放在 title/subtitle

ListTile(
  title: Text("Location"),
  subtitle: if (_currentPosition != null) Text(_currentAddress),
  trailing: IconButton(...),
),

这给出了一个错误 "Expected an identifier. dart(missing_identifier)"

你必须这样做:

subtitle: _currentPosition == null?
        Text('No position found') //code if above statement is true
        :Text(_currentAddress), //code if above statement is false