esentis / string_extensions Goto Github PK
View Code? Open in Web Editor NEWUseful String extensions to save you time in production.
Home Page: https://pub.dev/packages/string_extensions
License: BSD 3-Clause "New" or "Revised" License
Useful String extensions to save you time in production.
Home Page: https://pub.dev/packages/string_extensions
License: BSD 3-Clause "New" or "Revised" License
A method that detects and replaces common symbol uses as letters. E.g. the word stef@n1a
could be "translated" to stefania
.
I think a method that removes symbols would be quite useful. For instance, if a user writes something like "Μαρία@ t!1he 3$rd!!!!" for example, you get "Μαρία the 3rd".
A method called .onlyLetters()
seems to depreciate since v0.2.3
, and is renamed to onlyLatin
, is that correct?
Wouldn't it be nice to add a method that combines onlyLatin
and onlyGreek
named onlyLetters
?
extension InsertAt on String {
String insertAt(int i, String value) {
final start = substring(0, i);
final end = substring(i);
return start + value + end;
}
}
Not so much a feature request, more a design question to satisfy my curiosity. If something can be done about it, all the better!
This code gives an error that "A value of type 'String?' can't be assigned to a variable of type 'String'". IMHO this should be the ideal way to use the extension properties.
String foo = "foo".capitalize;
Instead we are forced to use a !
if we know the initial string to not be null.
String foo = "foo".capitalize!;
I understand that the advantage of the current approach is so we can easily work with nullable strings like this.
String? bar = maybe ? "not-null" : null;
String? biz = bar.capitalize;
However it seems more appropriate to force the usage of the ?
operator where things might be null instead of forcing the !
operator where we know they aren't null, like so.
String foo = "foo".capitalize; // Should be good
String? biz = bar?.capitalize; // Should be good. Forcing ? is appropriate since bar may be null
String foo = "foo".capitalize!; // Should be bad. "foo" is known to not be null, so .capitalize should be the same
String? biz = bar.capitalize; // Should be bad. bar may be null so it shouldn't have a .capitalize property. use ?.capitalize instead
I know changing it would break backwards compatibility, so I'm not requesting it be changed, but if I'm missing something and the current approach was chosen for some other benefit I'm not aware of, I'd love to learn what that is (I'm kind of new to dart and exploring its mechanisms). Maybe there can be two extension classes, one on String
and the other on String?
to keep backwards compatibility? (The latter could easily be implemented in terms of the former, though importing both may cause name collisions)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.