Git Product home page Git Product logo

esentis / string_extensions Goto Github PK

View Code? Open in Web Editor NEW
5.0 2.0 2.0 612 KB

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

Dart 100.00%
string-extensions flutter-plugin flutter dartlang text-normalization string-manipulation string-formatter string-validation string-normalization string-matching

string_extensions's Introduction

String Extensions

Version Version
Documentation
Version Coverage Status


string_extensions's People

Contributors

esentis avatar gbrandtio avatar zonaro avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

gbrandtio zonaro

string_extensions's Issues

symbol replacement with letters

suggestion

A method that detects and replaces common symbol uses as letters. E.g. the word stef@n1a could be "translated" to stefania.

add `removeSymbols` method

suggestion

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".

depreciated `onlyLetters` method

quiestion

A method called .onlyLetters() seems to depreciate since v0.2.3, and is renamed to onlyLatin, is that correct?

suggestion

Wouldn't it be nice to add a method that combines onlyLatin and onlyGreek named onlyLetters?

InsertAt

extension InsertAt on String {
String insertAt(int i, String value) {
final start = substring(0, i);
final end = substring(i);
return start + value + end;
}
}

Why is `MiscExtensions` an extension on `String?` and not on `String`

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.