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
boolisBlank(String? s) => s ==null|| s.trim().isEmpty;
I am new to Dart (learning it for Flutter) and expect that trim will create a new String to check if it is blank.
Is my assumption correct? I cannot confirm this in code since String is abstract, and I could not find an implementation of it (I think it's implemented like a native method in Java, though 😄 ).
Would you accept a PR that avoids the new string creation by checking if each code point of the original string is whitespace?
The implementation I have locally is the following:
It's surely a bit long and verbose, but I don't think it's hard to understand.
What do you think about it?
One problem that might arise in the future will be if new codepoints in Unicode become whitespaces, which will require a code change in this library.
The text was updated successfully, but these errors were encountered:
niktekusho
changed the title
More efficient isBlank check (probably)
More efficient isBlank check (probably)
Oct 24, 2022
Hi, thank you for the awesome library.
I noticed that
isBlank
is implemented as:quiver-dart/lib/strings.dart
Line 19 in d9bf68e
I am new to Dart (learning it for Flutter) and expect that
trim
will create a new String to check if it is blank.Is my assumption correct? I cannot confirm this in code since
String
isabstract
, and I could not find an implementation of it (I think it's implemented like anative
method in Java, though 😄 ).Would you accept a PR that avoids the new string creation by checking if each code point of the original string is whitespace?
The implementation I have locally is the following:
Here are some incomplete tests (imports are from Flutter; thus, they would need a replacement from the tests package):
It's surely a bit long and verbose, but I don't think it's hard to understand.
What do you think about it?
One problem that might arise in the future will be if new codepoints in Unicode become whitespaces, which will require a code change in this library.
The text was updated successfully, but these errors were encountered: