I want to conditionally pass an argument while using the widget. Is there any way to do so?
...
return ListTile(
title: Text("${product.name}"),
// want to conditionally pass subtitle, which is not the right syntax (???)
if(condition) subtitle: Text("subtitle"),
// I know about this
subtitle: condition? Text("subtitle"): null,
);
},
...
I know we can conditionally pass the value as null using ternary operator here but what I am looking for is to skip the argument itself.
The above example is for ListTile
widget. But my curiosity is to know the syntax for doing so for any widget.