Logo

Programming-Idioms

History of Idiom 110 > diff from v50 to v51

Edit summary for version 51 by programming-idioms.org:
New Dart implementation by user [programming-idioms.org]

Version 50

2020-08-09, 18:00:25

Version 51

2020-08-09, 18:01:22

Idiom #110 Check if string is blank

Set boolean blank to true if string s is empty, or null, or contains only whitespace ; false otherwise.

Idiom #110 Check if string is blank

Set boolean blank to true if string s is empty, or null, or contains only whitespace ; false otherwise.

Code
bool blank = s?.trim()?.isEmpty ?? true;
Comments bubble
? -> null safe check
?? -> on null
Origin
https://stackoverflow.com/a/52948927