Skip to content

Instantly share code, notes, and snippets.

@brunoalfred
Created November 14, 2021 12:05
Show Gist options
  • Select an option

  • Save brunoalfred/f29a36aee2115ad59567644e2c73b41f to your computer and use it in GitHub Desktop.

Select an option

Save brunoalfred/f29a36aee2115ad59567644e2c73b41f to your computer and use it in GitHub Desktop.
Basics of Dart extension.
extension StringExtension on String {
bool get isValidEmail {
final emailRegExp = RegExp(r"^[a-zA-Z0-9.]+@[a-zA-Z0-9]+\.[a-zA-Z]+");
return emailRegExp.hasMatch(this);
}
/*
* In Documentation its supported with implementation as :
*
* String operator &(String other) => '$this $other';
*
* */
String concatWithSpace(String other) {
return '$this $other';
}
}
void main(){
dynamic ans = 'bruno@bruno.com'.isValidEmail;
'hello'.concatWithSpace('Bruno')
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment