Created
November 14, 2021 12:05
-
-
Save brunoalfred/f29a36aee2115ad59567644e2c73b41f to your computer and use it in GitHub Desktop.
Basics of Dart extension.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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