I have a Message object, with optional string title and required string message
I want to display the title, or if it's null or empty, display the message.
Since the title could be an empty string "", I can't just write msg.title ?? msg.message.
Now I'm writing it like this:
// the Message object
String? title;
String message;
// display
Text(msg.title?.isEmpty ?? true
? msg.message
: msg.title!)
This is ridiculously long and complicated. Is there a better way to do this?
Thanks everyone, I've learned a lot from your answers!<3