Logo

Programming-Idioms

History of Idiom 110 > diff from v83 to v84

Edit summary for version 84 by programming-idioms.org:
[Dart] +DemoURL

Version 83

2022-03-03, 22:39:47

Version 84

2022-03-03, 22:41:51

Idiom #110 Check if string is blank

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

Idiom #110 Check if string is blank

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

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