Logo

Programming-Idioms

History of Idiom 110 > diff from v48 to v49

Edit summary for version 49 by Cukrus:
[Dart] shorter and cleaner code, that also might teach dart operators

Version 48

2020-02-09, 16:35:29

Version 49

2020-07-28, 12:05:01

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.

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