You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Text shouldn't throw an error if I give it a null String. It should handle that gracefully and display the same as if I gave it an empty String. Otherwise, you create more work for me, processing null Strings to empty Strings, and from what I've found so far, Dart is bad at things like that compared to Kotlin.
You can use Text(variable ?? "") which is the same with Swift and Kotlin, I think. And once Dart NNBD support lands, you will hopefully catch most of not all "optional type" problems at compile time.
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.
Activity
sma commentedon Sep 13, 2019
You can use
Text(variable ?? "")which is the same with Swift and Kotlin, I think. And once Dart NNBD support lands, you will hopefully catch most of not all "optional type" problems at compile time.[-]Allow null text for `Text` widget[/-][+]Allow null `String` for `Text` widget[/+]ScottPierce commentedon Sep 14, 2019
I didn't know about the
??operator. Thank you. That's far more convenient than what I've been doing.github-actions commentedon Aug 28, 2021
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of
flutter doctor -vand a minimal reproduction of the issue.