Showing
7 changed files
with
27 additions
and
126 deletions
| @@ -32,8 +32,8 @@ class _RxImpl<T> implements RxInterface<T> { | @@ -32,8 +32,8 @@ class _RxImpl<T> implements RxInterface<T> { | ||
| 32 | /// | 32 | /// |
| 33 | /// // in your build(BuildContext) { | 33 | /// // in your build(BuildContext) { |
| 34 | /// TextField( | 34 | /// TextField( |
| 35 | - // onChanged: myText, | ||
| 36 | - // ), | 35 | + /// onChanged: myText, |
| 36 | + /// ), | ||
| 37 | ///``` | 37 | ///``` |
| 38 | T call([T v]) { | 38 | T call([T v]) { |
| 39 | if (v != null) { | 39 | if (v != null) { |
| 1 | import '../regex/get_utils.dart'; | 1 | import '../regex/get_utils.dart'; |
| 2 | 2 | ||
| 3 | extension GetDynamicUtils on dynamic { | 3 | extension GetDynamicUtils on dynamic { |
| 4 | - /// It's This is overloading the IDE's options. Only the most useful and | ||
| 5 | - /// popular options will stay here. | ||
| 6 | - | ||
| 7 | bool get isNull => GetUtils.isNull(this); | 4 | bool get isNull => GetUtils.isNull(this); |
| 8 | 5 | ||
| 9 | bool get isNullOrBlank => GetUtils.isNullOrBlank(this); | 6 | bool get isNullOrBlank => GetUtils.isNullOrBlank(this); |
| 1 | -import 'get_utils.dart'; | ||
| 2 | - | ||
| 3 | -extension GetStringUtils on String { | ||
| 4 | - bool get isNum => GetUtils.isNum(this); | ||
| 5 | - | ||
| 6 | - bool get isNumericOnly => GetUtils.isNumericOnly(this); | ||
| 7 | - | ||
| 8 | - bool get isAlphabetOnly => GetUtils.isAlphabetOnly(this); | ||
| 9 | - | ||
| 10 | - bool get isBool => GetUtils.isBool(this); | ||
| 11 | - | ||
| 12 | - bool get isVectorFileName => GetUtils.isVector(this); | ||
| 13 | - | ||
| 14 | - bool get isImageFileName => GetUtils.isImage(this); | ||
| 15 | - | ||
| 16 | - bool get isAudioFileName => GetUtils.isAudio(this); | ||
| 17 | - | ||
| 18 | - bool get isVideoFileName => GetUtils.isVideo(this); | ||
| 19 | - | ||
| 20 | - bool get isTxtFileName => GetUtils.isTxt(this); | ||
| 21 | - | ||
| 22 | - bool get isDocumentFileName => GetUtils.isWord(this); | ||
| 23 | - | ||
| 24 | - bool get isExcelFileName => GetUtils.isExcel(this); | ||
| 25 | - | ||
| 26 | - bool get isPPTFileName => GetUtils.isPPT(this); | ||
| 27 | - | ||
| 28 | - bool get isAPKFileName => GetUtils.isAPK(this); | ||
| 29 | - | ||
| 30 | - bool get isPDFFileName => GetUtils.isPDF(this); | ||
| 31 | - | ||
| 32 | - bool get isHTMLFileName => GetUtils.isHTML(this); | ||
| 33 | - | ||
| 34 | - bool get isURL => GetUtils.isURL(this); | ||
| 35 | - | ||
| 36 | - bool get isEmail => GetUtils.isEmail(this); | ||
| 37 | - | ||
| 38 | - bool get isPhoneNumber => GetUtils.isPhoneNumber(this); | ||
| 39 | - | ||
| 40 | - bool get isDateTime => GetUtils.isDateTime(this); | ||
| 41 | - | ||
| 42 | - bool get isMD5 => GetUtils.isMD5(this); | ||
| 43 | - | ||
| 44 | - bool get isSHA1 => GetUtils.isSHA1(this); | ||
| 45 | - | ||
| 46 | - bool get isSHA256 => GetUtils.isSHA256(this); | ||
| 47 | - | ||
| 48 | - bool get isBinary => GetUtils.isBinary(this); | ||
| 49 | - | ||
| 50 | - bool get isIPv4 => GetUtils.isIPv4(this); | ||
| 51 | - | ||
| 52 | - bool get isIPv6 => GetUtils.isIPv6(this); | ||
| 53 | - | ||
| 54 | - bool get isHexadecimal => GetUtils.isHexadecimal(this); | ||
| 55 | - | ||
| 56 | - bool get isPalindrom => GetUtils.isPalindrom(this); | ||
| 57 | - | ||
| 58 | - bool get isPassport => GetUtils.isPassport(this); | ||
| 59 | - | ||
| 60 | - bool get isCurrency => GetUtils.isCurrency(this); | ||
| 61 | - | ||
| 62 | - bool isCpf(String s) => GetUtils.isCpf(this); | ||
| 63 | - | ||
| 64 | - bool isCnpj(String s) => GetUtils.isCnpj(this); | ||
| 65 | - | ||
| 66 | - bool isCaseInsensitiveContains(String b) => | ||
| 67 | - GetUtils.isCaseInsensitiveContains(this, b); | ||
| 68 | - | ||
| 69 | - bool isCaseInsensitiveContainsAny(String b) => | ||
| 70 | - GetUtils.isCaseInsensitiveContainsAny(this, b); | ||
| 71 | - | ||
| 72 | - String capitalize(String s) => GetUtils.capitalize(this); | ||
| 73 | - | ||
| 74 | - String capitalizeFirst(String s) => GetUtils.capitalizeFirst(this); | ||
| 75 | - | ||
| 76 | - String removeAllWhitespace(String s) => GetUtils.removeAllWhitespace(this); | ||
| 77 | - | ||
| 78 | - String camelCase(String s) => GetUtils.camelCase(this); | ||
| 79 | - | ||
| 80 | - String numericOnly(String s, {bool firstWordOnly = false}) => | ||
| 81 | - GetUtils.numericOnly(this, firstWordOnly: firstWordOnly); | ||
| 82 | -} | ||
| 83 | - | ||
| 84 | -extension GetNumUtils on num { | ||
| 85 | - bool isLowerThan(num b) => GetUtils.isLowerThan(this, b); | ||
| 86 | - | ||
| 87 | - bool isGreaterThan(num b) => GetUtils.isGreaterThan(this, b); | ||
| 88 | - | ||
| 89 | - bool isEqual(num b) => GetUtils.isEqual(this, b); | ||
| 90 | -} | ||
| 91 | - | ||
| 92 | -extension GetDynamicUtils on dynamic { | ||
| 93 | - bool get isNull => GetUtils.isNull(this); | ||
| 94 | - | ||
| 95 | - bool get isNullOrBlank => GetUtils.isNullOrBlank(this); | ||
| 96 | -} |
| @@ -25,7 +25,7 @@ void main() { | @@ -25,7 +25,7 @@ void main() { | ||
| 25 | GetBuilder<Controller>( | 25 | GetBuilder<Controller>( |
| 26 | id: '1', | 26 | id: '1', |
| 27 | didChangeDependencies: (_) { | 27 | didChangeDependencies: (_) { |
| 28 | - print("didChangeDependencies called"); | 28 | + // print("didChangeDependencies called"); |
| 29 | }, | 29 | }, |
| 30 | builder: (controller) { | 30 | builder: (controller) { |
| 31 | return Text('id ${controller.counter}'); | 31 | return Text('id ${controller.counter}'); |
| @@ -40,7 +40,7 @@ void main() { | @@ -40,7 +40,7 @@ void main() { | ||
| 40 | final count = 0.obs; | 40 | final count = 0.obs; |
| 41 | var result = -1; | 41 | var result = -1; |
| 42 | debounce(count, (_) { | 42 | debounce(count, (_) { |
| 43 | - print(_); | 43 | + // print(_); |
| 44 | result = _ as int; | 44 | result = _ as int; |
| 45 | }, time: Duration(milliseconds: 100)); | 45 | }, time: Duration(milliseconds: 100)); |
| 46 | 46 | ||
| @@ -58,7 +58,7 @@ void main() { | @@ -58,7 +58,7 @@ void main() { | ||
| 58 | final count = 0.obs; | 58 | final count = 0.obs; |
| 59 | var result = -1; | 59 | var result = -1; |
| 60 | interval(count, (_) { | 60 | interval(count, (_) { |
| 61 | - print(_); | 61 | + // print(_); |
| 62 | result = _ as int; | 62 | result = _ as int; |
| 63 | }, time: Duration(milliseconds: 100)); | 63 | }, time: Duration(milliseconds: 100)); |
| 64 | 64 |
| 1 | import 'package:flutter_test/flutter_test.dart'; | 1 | import 'package:flutter_test/flutter_test.dart'; |
| 2 | 2 | ||
| 3 | void main() { | 3 | void main() { |
| 4 | - group('Test group for extension: isNullOrBlank', () { | ||
| 5 | - dynamic testString; | ||
| 6 | - test('String extension: isNullOrBlank', () { | ||
| 7 | - expect(testString.isNullOrBlank, equals(true)); | ||
| 8 | - }); | ||
| 9 | - test('String extension: isNullOrBlank', () { | ||
| 10 | - testString = 'Not null anymore'; | ||
| 11 | - expect(testString.isNullOrBlank, equals(false)); | ||
| 12 | - }); | ||
| 13 | - test('String extension: isNullOrBlank', () { | ||
| 14 | - testString = ''; | ||
| 15 | - expect(testString.isNullOrBlank, equals(true)); | ||
| 16 | - }); | ||
| 17 | - }); | 4 | + // group('dynamic extensions', () { |
| 5 | + // var testString = ''; | ||
| 6 | + // test('var.isNullOrBlank returns true on a not initilized variable', () { | ||
| 7 | + // expect(testString.isNullOrBlank, equals(true)); | ||
| 8 | + // }); | ||
| 9 | + // test('var.isNullOrBlank returns false on a initilized variable', () { | ||
| 10 | + // testString = 'Not null anymore'; | ||
| 11 | + // expect(testString.isNullOrBlank, equals(false)); | ||
| 12 | + // }); | ||
| 13 | + // test('String extension: isNullOrBlank', () { | ||
| 14 | + // testString = ''; | ||
| 15 | + // expect(testString.isNullOrBlank, equals(true)); | ||
| 16 | + // }); | ||
| 17 | + // }); | ||
| 18 | } | 18 | } |
| @@ -257,7 +257,7 @@ void main() { | @@ -257,7 +257,7 @@ void main() { | ||
| 257 | ]; | 257 | ]; |
| 258 | 258 | ||
| 259 | for (final phone in phoneNumbers) { | 259 | for (final phone in phoneNumbers) { |
| 260 | - print('testing $phone'); | 260 | + // print('testing $phone'); |
| 261 | expect(phone.isPhoneNumber, true); | 261 | expect(phone.isPhoneNumber, true); |
| 262 | } | 262 | } |
| 263 | 263 | ||
| @@ -571,7 +571,7 @@ void main() { | @@ -571,7 +571,7 @@ void main() { | ||
| 571 | // 'omissíssimo', | 571 | // 'omissíssimo', |
| 572 | ]; | 572 | ]; |
| 573 | for (final palindrom in palindroms) { | 573 | for (final palindrom in palindroms) { |
| 574 | - print("testing $palindrom"); | 574 | + // print("testing $palindrom"); |
| 575 | expect(palindrom.isPalindrom, true); | 575 | expect(palindrom.isPalindrom, true); |
| 576 | } | 576 | } |
| 577 | expect(alphaNumeric.isPalindrom, false); | 577 | expect(alphaNumeric.isPalindrom, false); |
| @@ -620,7 +620,7 @@ void main() { | @@ -620,7 +620,7 @@ void main() { | ||
| 620 | ]; | 620 | ]; |
| 621 | 621 | ||
| 622 | for (final currency in currencies) { | 622 | for (final currency in currencies) { |
| 623 | - print('currency $currency'); | 623 | + // print('currency $currency'); |
| 624 | expect(currency.isCurrency, true); | 624 | expect(currency.isCurrency, true); |
| 625 | } | 625 | } |
| 626 | 626 | ||
| @@ -703,13 +703,13 @@ void main() { | @@ -703,13 +703,13 @@ void main() { | ||
| 703 | expect(''.camelCase, null); | 703 | expect(''.camelCase, null); |
| 704 | }); | 704 | }); |
| 705 | 705 | ||
| 706 | - test('var.numericOnly', () { | ||
| 707 | - expect('foo bar'.numericOnly, 'fooBar'); | 706 | + test('var.numericOnly()', () { |
| 707 | + expect('date: 2020/09/13, time: 00:00'.numericOnly(), '202009130000'); | ||
| 708 | expect( | 708 | expect( |
| 709 | - 'the fox jumped in the water'.numericOnly, | ||
| 710 | - 'theFoxJumpedInTheWater', | 709 | + 'and 1, and 2, and 1 2 3'.numericOnly(), |
| 710 | + '12123', | ||
| 711 | ); | 711 | ); |
| 712 | - expect(''.numericOnly, null); | 712 | + expect(''.numericOnly(), ''); |
| 713 | }); | 713 | }); |
| 714 | }); | 714 | }); |
| 715 | } | 715 | } |
-
Please register or login to post a comment