Nipodemos
Committed by GitHub

Merge branch 'master' into master

@@ -4,7 +4,7 @@ @@ -4,7 +4,7 @@
4 4
5 [![pub package](https://img.shields.io/pub/v/get.svg?label=get&color=blue)](https://pub.dev/packages/get) 5 [![pub package](https://img.shields.io/pub/v/get.svg?label=get&color=blue)](https://pub.dev/packages/get)
6 ![building](https://github.com/jonataslaw/get/workflows/build/badge.svg) 6 ![building](https://github.com/jonataslaw/get/workflows/build/badge.svg)
7 -[![Gitter](https://badges.gitter.im/flutter_get/community.svg)](https://gitter.im/flutter_get/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) 7 +[![Discord Shield](https://discordapp.com/api/guilds/722900883784073290/widget.png?style=shield)](https://discord.com/invite/9Hpt99N)
8 <a href="https://github.com/Solido/awesome-flutter"> 8 <a href="https://github.com/Solido/awesome-flutter">
9 <img alt="Awesome Flutter" src="https://img.shields.io/badge/Awesome-Flutter-blue.svg?longCache=true&style=flat-square" /> 9 <img alt="Awesome Flutter" src="https://img.shields.io/badge/Awesome-Flutter-blue.svg?longCache=true&style=flat-square" />
10 </a> 10 </a>
@@ -40,7 +40,7 @@ @@ -40,7 +40,7 @@
40 40
41 [**Slack (English)**](https://communityinviter.com/apps/getxworkspace/getx) 41 [**Slack (English)**](https://communityinviter.com/apps/getxworkspace/getx)
42 42
43 -[**Discord (English and Portuguese)**](https://discord.com/invite/9Hpt99N) 43 +[**Discord (English, Spanish and Portuguese)**](https://discord.com/invite/9Hpt99N)
44 44
45 [**Telegram (Portuguese)**](https://t.me/joinchat/PhdbJRmsZNpAqSLJL6bH7g) 45 [**Telegram (Portuguese)**](https://t.me/joinchat/PhdbJRmsZNpAqSLJL6bH7g)
46 46
@@ -466,6 +466,19 @@ Get.config( @@ -466,6 +466,19 @@ Get.config(
466 ) 466 )
467 ``` 467 ```
468 468
  469 +Opcjonalnie możesz przekierować wszystkie logi z Get by używać swojej ulubionej paczki i zbierać w niej logi.
  470 +
  471 +```dart
  472 +GetMaterialApp(
  473 + enableLog: true,
  474 + logWriterCallback: localLogWriter,
  475 + );
  476 + void localLogWriter(String text, {bool isError = false}) {
  477 + // tutaj przekaż wiadomosci do ulubionej paczki
  478 + // pamiętaj że nawet jeśli "enableLog: false" logi i tak będą wysłane w tym callbacku
  479 + // Musisz sprawdzić konfiguracje flag jeśli chcesz przez GetConfig.isLogEnable
  480 + }
  481 +
469 ## Video tłumaczące inne funkcjonalności GetX 482 ## Video tłumaczące inne funkcjonalności GetX
470 483
471 484
@@ -154,7 +154,7 @@ packages: @@ -154,7 +154,7 @@ packages:
154 name: crypto 154 name: crypto
155 url: "https://pub.dartlang.org" 155 url: "https://pub.dartlang.org"
156 source: hosted 156 source: hosted
157 - version: "2.1.5" 157 + version: "2.1.4"
158 csslib: 158 csslib:
159 dependency: transitive 159 dependency: transitive
160 description: 160 description:
@@ -73,7 +73,7 @@ packages: @@ -73,7 +73,7 @@ packages:
73 path: ".." 73 path: ".."
74 relative: true 74 relative: true
75 source: path 75 source: path
76 - version: "3.4.6" 76 + version: "3.5.1"
77 http_parser: 77 http_parser:
78 dependency: transitive 78 dependency: transitive
79 description: 79 description:

26.7 KB | W: | H:

115 KB | W: | H:

  • 2-up
  • Swipe
  • Onion skin
  1 +
1 import 'package:get/instance_manager.dart'; 2 import 'package:get/instance_manager.dart';
  3 +import 'dart:developer' as developer;
2 4
3 typedef LogWriterCallback = void Function(String text, {bool isError}); 5 typedef LogWriterCallback = void Function(String text, {bool isError});
4 6
5 void defaultLogWriterCallback(String value, {bool isError = false}) { 7 void defaultLogWriterCallback(String value, {bool isError = false}) {
6 - if (isError || GetConfig.isLogEnable) print(value); 8 + if (isError || GetConfig.isLogEnable) developer.log(value, name: 'GETX');
7 } 9 }
  1 +import 'package:flutter/cupertino.dart';
1 import 'package:get/src/core/log.dart'; 2 import 'package:get/src/core/log.dart';
2 import 'package:get/src/navigation/root/smart_management.dart'; 3 import 'package:get/src/navigation/root/smart_management.dart';
3 import 'package:get/src/state_manager/rx/rx_interface.dart'; 4 import 'package:get/src/state_manager/rx/rx_interface.dart';
@@ -154,7 +155,7 @@ class GetInstance { @@ -154,7 +155,7 @@ class GetInstance {
154 final i = _singl[key].getDependency(); 155 final i = _singl[key].getDependency();
155 if (i is DisposableInterface) { 156 if (i is DisposableInterface) {
156 i.onStart(); 157 i.onStart();
157 - GetConfig.log('[GETX] $key has been initialized'); 158 + GetConfig.log('$key has been initialized');
158 } 159 }
159 } 160 }
160 161
@@ -202,7 +203,7 @@ class GetInstance { @@ -202,7 +203,7 @@ class GetInstance {
202 if (!_factory.containsKey(key)) 203 if (!_factory.containsKey(key))
203 throw "$S not found. You need call put<$S>($S()) before"; 204 throw "$S not found. You need call put<$S>($S()) before";
204 205
205 - GetConfig.log('[GETX] $S instance was created at that time'); 206 + GetConfig.log('$S instance was created at that time');
206 S _value = put<S>(_factory[key].builder() as S); 207 S _value = put<S>(_factory[key].builder() as S);
207 208
208 _initDependencies<S>(name: tag); 209 _initDependencies<S>(name: tag);
@@ -248,15 +249,15 @@ class GetInstance { @@ -248,15 +249,15 @@ class GetInstance {
248 249
249 return queue.add<bool>(() async { 250 return queue.add<bool>(() async {
250 if (!_singl.containsKey(newKey)) { 251 if (!_singl.containsKey(newKey)) {
251 - GetConfig.log('[GETX] Instance "$newKey" already removed.',  
252 - isError: true); 252 +
  253 + GetConfig.log('Instance $newKey already been removed.', isError: true);
253 return false; 254 return false;
254 } 255 }
255 256
256 FcBuilder builder = _singl[newKey] as FcBuilder; 257 FcBuilder builder = _singl[newKey] as FcBuilder;
257 if (builder.permanent && !force) { 258 if (builder.permanent && !force) {
258 GetConfig.log( 259 GetConfig.log(
259 - '[GETX] "$newKey" has been marked as permanent, SmartManagement is not authorized to delete it.', 260 + '[$newKey] has been marked as permanent, SmartManagement is not authorized to delete it.',
260 isError: true); 261 isError: true);
261 return false; 262 return false;
262 } 263 }
@@ -267,14 +268,14 @@ class GetInstance { @@ -267,14 +268,14 @@ class GetInstance {
267 } 268 }
268 if (i is DisposableInterface) { 269 if (i is DisposableInterface) {
269 await i.onClose(); 270 await i.onClose();
270 - GetConfig.log('[GETX] "$newKey" onClose() called'); 271 + GetConfig.log('onClose of $newKey called');
271 } 272 }
272 273
273 _singl.removeWhere((oldKey, value) => (oldKey == newKey)); 274 _singl.removeWhere((oldKey, value) => (oldKey == newKey));
274 if (_singl.containsKey(newKey)) { 275 if (_singl.containsKey(newKey)) {
275 - GetConfig.log('[GETX] error removing object "$newKey"', isError: true); 276 + GetConfig.log('error on remove object $newKey', isError: true);
276 } else { 277 } else {
277 - GetConfig.log('[GETX] "$newKey" deleted from memory'); 278 + GetConfig.log('$newKey deleted from memory');
278 } 279 }
279 // _routesKey?.remove(key); 280 // _routesKey?.remove(key);
280 return true; 281 return true;
@@ -72,13 +72,13 @@ class GetObserver extends NavigatorObserver { @@ -72,13 +72,13 @@ class GetObserver extends NavigatorObserver {
72 String routeName = name(route); 72 String routeName = name(route);
73 73
74 if (isSnackbar) { 74 if (isSnackbar) {
75 - GetConfig.log("[GETX] OPEN SNACKBAR $routeName"); 75 + GetConfig.log("OPEN SNACKBAR $routeName");
76 } else if (isBottomSheet) { 76 } else if (isBottomSheet) {
77 - GetConfig.log("[GETX] OPEN $routeName"); 77 + GetConfig.log("OPEN $routeName");
78 } else if (isDialog) { 78 } else if (isDialog) {
79 - GetConfig.log("[GETX] OPEN $routeName"); 79 + GetConfig.log("OPEN $routeName");
80 } else if (isGetPageRoute) { 80 } else if (isGetPageRoute) {
81 - GetConfig.log("[GETX] GOING TO ROUTE $routeName"); 81 + GetConfig.log("GOING TO ROUTE $routeName");
82 } 82 }
83 GetConfig.currentRoute = routeName; 83 GetConfig.currentRoute = routeName;
84 84
@@ -107,13 +107,13 @@ class GetObserver extends NavigatorObserver { @@ -107,13 +107,13 @@ class GetObserver extends NavigatorObserver {
107 String routeName = name(route); 107 String routeName = name(route);
108 108
109 if (isSnackbar) { 109 if (isSnackbar) {
110 - GetConfig.log("[GETX] CLOSE SNACKBAR $routeName"); 110 + GetConfig.log("CLOSE SNACKBAR $routeName");
111 } else if (isBottomSheet) { 111 } else if (isBottomSheet) {
112 - GetConfig.log("[GETX] CLOSE $routeName"); 112 + GetConfig.log("CLOSE $routeName");
113 } else if (isDialog) { 113 } else if (isDialog) {
114 - GetConfig.log("[GETX] CLOSE $routeName"); 114 + GetConfig.log("CLOSE $routeName");
115 } else if (isGetPageRoute) { 115 } else if (isGetPageRoute) {
116 - GetConfig.log("[GETX] CLOSE TO ROUTE $routeName"); 116 + GetConfig.log("CLOSE TO ROUTE $routeName");
117 } 117 }
118 GetConfig.currentRoute = routeName; 118 GetConfig.currentRoute = routeName;
119 119
@@ -136,8 +136,8 @@ class GetObserver extends NavigatorObserver { @@ -136,8 +136,8 @@ class GetObserver extends NavigatorObserver {
136 void didReplace({Route newRoute, Route oldRoute}) { 136 void didReplace({Route newRoute, Route oldRoute}) {
137 super.didReplace(newRoute: newRoute, oldRoute: oldRoute); 137 super.didReplace(newRoute: newRoute, oldRoute: oldRoute);
138 138
139 - GetConfig.log("[GETX] REPLACE ROUTE ${oldRoute?.settings?.name}");  
140 - GetConfig.log("[GETX] NEW ROUTE ${newRoute?.settings?.name}"); 139 + GetConfig.log("REPLACE ROUTE ${oldRoute?.settings?.name}");
  140 + GetConfig.log("NEW ROUTE ${newRoute?.settings?.name}");
141 141
142 GetConfig.currentRoute = name(newRoute); 142 GetConfig.currentRoute = name(newRoute);
143 143
@@ -158,7 +158,7 @@ class GetObserver extends NavigatorObserver { @@ -158,7 +158,7 @@ class GetObserver extends NavigatorObserver {
158 @override 158 @override
159 void didRemove(Route route, Route previousRoute) { 159 void didRemove(Route route, Route previousRoute) {
160 super.didRemove(route, previousRoute); 160 super.didRemove(route, previousRoute);
161 - GetConfig.log("[GETX] REMOVING ROUTE ${route?.settings?.name}"); 161 + GetConfig.log("REMOVING ROUTE ${route?.settings?.name}");
162 162
163 _routeSend.update((value) { 163 _routeSend.update((value) {
164 value.route = previousRoute; 164 value.route = previousRoute;
@@ -100,7 +100,7 @@ class Worker { @@ -100,7 +100,7 @@ class Worker {
100 final String type; 100 final String type;
101 101
102 void _message() { 102 void _message() {
103 - GetConfig.log('[Getx] Worker $type disposed'); 103 + GetConfig.log('Worker $type disposed');
104 } 104 }
105 105
106 void dispose() { 106 void dispose() {
1 import 'dart:async'; 1 import 'dart:async';
2 -  
3 import 'package:flutter/widgets.dart'; 2 import 'package:flutter/widgets.dart';
4 import 'package:get/src/state_manager/rx/rx_interface.dart'; 3 import 'package:get/src/state_manager/rx/rx_interface.dart';
5 -  
6 import 'rx_impl.dart'; 4 import 'rx_impl.dart';
7 5
8 -Widget obx(Widget Function() builder) {  
9 - final b = builder;  
10 - return Obxx(b);  
11 -}  
12 -  
13 -/// it's very very very very experimental  
14 -class Obxx extends StatelessWidget {  
15 - final Widget Function() builder;  
16 - Obxx(this.builder, {Key key}) : super(key: key);  
17 - final RxInterface _observer = Rx();  
18 6
19 - @override  
20 - Widget build(_) {  
21 - _observer.subject.stream.listen((data) => (_ as Element)..markNeedsBuild());  
22 - final observer = getObs;  
23 - getObs = _observer;  
24 - final result = builder();  
25 - getObs = observer;  
26 - return result;  
27 - }  
28 -}  
29 7
30 /// The simplest reactive widget in GetX. 8 /// The simplest reactive widget in GetX.
31 /// 9 ///
@@ -96,7 +74,7 @@ class _ObxState extends State<Obx> { @@ -96,7 +74,7 @@ class _ObxState extends State<Obx> {
96 /// false.obs, 74 /// false.obs,
97 /// ), 75 /// ),
98 76
99 -// TODO: change T to a proper Rx interfase, that includes the accessor for ::value 77 +// TODO: change T to a proper Rx interface, that includes the accessor for ::value
100 class ObxValue<T extends RxInterface> extends StatefulWidget { 78 class ObxValue<T extends RxInterface> extends StatefulWidget {
101 final Widget Function(T) builder; 79 final Widget Function(T) builder;
102 final T data; 80 final T data;
@@ -36,6 +36,6 @@ class MixinBuilder<T extends GetxController> extends StatelessWidget { @@ -36,6 +36,6 @@ class MixinBuilder<T extends GetxController> extends StatelessWidget {
36 id: id, 36 id: id,
37 didChangeDependencies: didChangeDependencies, 37 didChangeDependencies: didChangeDependencies,
38 didUpdateWidget: didUpdateWidget, 38 didUpdateWidget: didUpdateWidget,
39 - builder: (controller) => obx(() => builder.call(controller))); 39 + builder: (controller) => Obx(() => builder.call(controller)));
40 } 40 }
41 } 41 }
  1 +import 'package:flutter/material.dart';
  2 +import 'package:flutter/widgets.dart';
  3 +import 'package:flutter/foundation.dart';
  4 +
  5 +extension ContextExtensionss on BuildContext {
  6 + /// The same of [MediaQuery.of(context).size]
  7 + Size get mediaQuerySize => MediaQuery.of(this).size;
  8 +
  9 + /// The same of [MediaQuery.of(context).size.height]
  10 + /// Note: updates when you rezise your screen (like on a browser or desktop window)
  11 + double get height => mediaQuerySize.height;
  12 +
  13 + /// The same of [MediaQuery.of(context).size.width]
  14 + /// Note: updates when you rezise your screen (like on a browser or desktop window)
  15 + double get width => mediaQuerySize.width;
  16 +
  17 + /// Gives you the power to get a portion of the height.
  18 + /// Useful for responsive applications.
  19 + ///
  20 + /// [dividedBy] is for when you want to have a portion of the value you would get
  21 + /// like for example: if you want a value that represents a third of the screen
  22 + /// you can set it to 3, and you will get a third of the height
  23 + ///
  24 + /// [reducedBy] is a percentage value of how much of the height you want
  25 + /// if you for example want 46% of the height, then you reduce it by 56%.
  26 + double heightTransformer({double dividedBy = 1, double reducedBy = 0.0}) {
  27 + return (mediaQuerySize.height -
  28 + ((mediaQuerySize.height / 100) * reducedBy)) /
  29 + dividedBy;
  30 + }
  31 +
  32 + /// Gives you the power to get a portion of the width.
  33 + /// Useful for responsive applications.
  34 + ///
  35 + /// [dividedBy] is for when you want to have a portion of the value you would get
  36 + /// like for example: if you want a value that represents a third of the screen
  37 + /// you can set it to 3, and you will get a third of the width
  38 + ///
  39 + /// [reducedBy] is a percentage value of how much of the width you want
  40 + /// if you for example want 46% of the width, then you reduce it by 56%.
  41 + double widthTransformer({double dividedBy = 1, double reducedBy = 0.0}) {
  42 + return (mediaQuerySize.width - ((mediaQuerySize.width / 100) * reducedBy)) /
  43 + dividedBy;
  44 + }
  45 +
  46 + /// Divide the height proportionally by the given value
  47 + double ratio({
  48 + double dividedBy = 1,
  49 + double reducedByW = 0.0,
  50 + double reducedByH = 0.0,
  51 + }) {
  52 + return heightTransformer(dividedBy: dividedBy, reducedBy: reducedByH) /
  53 + widthTransformer(dividedBy: dividedBy, reducedBy: reducedByW);
  54 + }
  55 +
  56 + /// similar to [MediaQuery.of(context).padding]
  57 + ThemeData get theme => Theme.of(this);
  58 +
  59 + /// similar to [MediaQuery.of(context).padding]
  60 + TextTheme get textTheme => Theme.of(this).textTheme;
  61 +
  62 + /// similar to [MediaQuery.of(context).padding]
  63 + EdgeInsets get mediaQueryPadding => MediaQuery.of(this).padding;
  64 +
  65 + /// similar to [MediaQuery.of(context).padding]
  66 + MediaQueryData get mediaQuery => MediaQuery.of(this);
  67 +
  68 + /// similar to [MediaQuery.of(context).viewPadding]
  69 + EdgeInsets get mediaQueryViewPadding => MediaQuery.of(this).viewPadding;
  70 +
  71 + /// similar to [MediaQuery.of(context).viewInsets]
  72 + EdgeInsets get mediaQueryViewInsets => MediaQuery.of(this).viewInsets;
  73 +
  74 + /// similar to [MediaQuery.of(context).orientation]
  75 + Orientation get orientation => MediaQuery.of(this).orientation;
  76 +
  77 + /// check if device is on landscape mode
  78 + bool get isLandscape => orientation == Orientation.landscape;
  79 +
  80 + /// check if device is on portrait mode
  81 + bool get isPortrait => orientation == Orientation.portrait;
  82 +
  83 + /// similar to [MediaQuery.of(this).devicePixelRatio]
  84 + double get devicePixelRatio => MediaQuery.of(this).devicePixelRatio;
  85 +
  86 + /// similar to [MediaQuery.of(this).textScaleFactor]
  87 + double get textScaleFactor => MediaQuery.of(this).textScaleFactor;
  88 +
  89 + /// get the shortestSide from screen
  90 + double get mediaQueryShortestSide => mediaQuerySize.shortestSide;
  91 +
  92 + /// True if width be larger than 800
  93 + bool get showNavbar => (width > 800);
  94 +
  95 + /// True if the shortestSide is smaller than 600p
  96 + bool get isPhone => (mediaQueryShortestSide < 600);
  97 +
  98 + /// True if the shortestSide is largest than 600p
  99 + bool get isSmallTablet => (mediaQueryShortestSide >= 600);
  100 +
  101 + /// True if the shortestSide is largest than 720p
  102 + bool get isLargeTablet => (mediaQueryShortestSide >= 720);
  103 +
  104 + /// True if the current device is Tablet
  105 + bool get isTablet => isSmallTablet || isLargeTablet;
  106 +
  107 + /// Returns a specific value according to the screen size
  108 + /// if the device width is higher than or equal to 1200 return [desktop] value.
  109 + /// if the device width is higher than or equal to 600 and less than 1200
  110 + /// return [tablet] value.
  111 + /// if the device width is less than 300 return [watch] value.
  112 + /// in other cases return [mobile] value.
  113 + T responsiveValue<T>({
  114 + T mobile,
  115 + T tablet,
  116 + T desktop,
  117 + T watch,
  118 + }) {
  119 + double deviceWidth = mediaQuerySize.shortestSide;
  120 +
  121 + if (kIsWeb) {
  122 + deviceWidth = mediaQuerySize.width;
  123 + }
  124 + if (deviceWidth >= 1200 && desktop != null) return desktop;
  125 + if (deviceWidth >= 600 && tablet != null) return tablet;
  126 + if (deviceWidth < 300 && watch != null) return watch;
  127 + return mobile;
  128 + }
  129 +}
  1 +import 'dart:math';
  2 +
  3 +extension Precision on double {
  4 + double toPrecision(int fractionDigits) {
  5 + double mod = pow(10, fractionDigits.toDouble());
  6 + return ((this * mod).round().toDouble() / mod);
  7 + }
  8 +}
  1 +import '../regex/get_utils.dart';
  2 +
  3 +extension GetDynamicUtils on dynamic {
  4 + /// It's This is overloading the IDE's options. Only the most useful and popular options will stay here.
  5 +
  6 + bool get isNull => GetUtils.isNull(this);
  7 + bool get isNullOrBlank => GetUtils.isNullOrBlank(this);
  8 +
  9 + // bool get isOneAKind => GetUtils.isOneAKind(this);
  10 + // bool isLengthLowerThan(int maxLength) =>
  11 + // GetUtils.isLengthLowerThan(this, maxLength);
  12 + // bool isLengthGreaterThan(int maxLength) =>
  13 + // GetUtils.isLengthGreaterThan(this, maxLength);
  14 + // bool isLengthGreaterOrEqual(int maxLength) =>
  15 + // GetUtils.isLengthGreaterOrEqual(this, maxLength);
  16 + // bool isLengthLowerOrEqual(int maxLength) =>
  17 + // GetUtils.isLengthLowerOrEqual(this, maxLength);
  18 + // bool isLengthEqualTo(int maxLength) =>
  19 + // GetUtils.isLengthEqualTo(this, maxLength);
  20 + // bool isLengthBetween(int minLength, int maxLength) =>
  21 + // GetUtils.isLengthBetween(this, minLength, maxLength);
  22 +}
  1 +export 'context_extensions.dart';
  2 +export 'double_extensions.dart';
  3 +export 'dynamic_extensions.dart';
  4 +export 'num_extensions.dart';
  5 +export 'string_extensions.dart';
  6 +export 'widget_extensions.dart';
  1 +import '../regex/get_utils.dart';
  2 +
  3 +extension GetNumUtils on num {
  4 + bool isLowerThan(num b) => GetUtils.isLowerThan(this, b);
  5 + bool isGreaterThan(num b) => GetUtils.isGreaterThan(this, b);
  6 + bool isEqual(num b) => GetUtils.isEqual(this, b);
  7 +}
  1 +import '../regex/get_utils.dart';
  2 +
  3 +extension GetStringUtils on String {
  4 + bool get isNum => GetUtils.isNum(this);
  5 + bool get isNumericOnly => GetUtils.isNumericOnly(this);
  6 + bool get isAlphabetOnly => GetUtils.isAlphabetOnly(this);
  7 + bool get isBool => GetUtils.isBool(this);
  8 + bool get isVectorFileName => GetUtils.isVector(this);
  9 + bool get isImageFileName => GetUtils.isImage(this);
  10 + bool get isAudioFileName => GetUtils.isAudio(this);
  11 + bool get isVideoFileName => GetUtils.isVideo(this);
  12 + bool get isTxtFileName => GetUtils.isTxt(this);
  13 + bool get isDocumentFileName => GetUtils.isWord(this);
  14 + bool get isExcelFileName => GetUtils.isExcel(this);
  15 + bool get isPPTFileName => GetUtils.isPPT(this);
  16 + bool get isAPKFileName => GetUtils.isAPK(this);
  17 + bool get isPDFFileName => GetUtils.isPDF(this);
  18 + bool get isHTMLFileName => GetUtils.isHTML(this);
  19 + bool get isURL => GetUtils.isURL(this);
  20 + bool get isEmail => GetUtils.isEmail(this);
  21 + bool get isPhoneNumber => GetUtils.isPhoneNumber(this);
  22 + bool get isDateTime => GetUtils.isDateTime(this);
  23 + bool get isMD5 => GetUtils.isMD5(this);
  24 + bool get isSHA1 => GetUtils.isSHA1(this);
  25 + bool get isSHA256 => GetUtils.isSHA256(this);
  26 + bool get isBinary => GetUtils.isBinary(this);
  27 + bool get isIPv4 => GetUtils.isIPv4(this);
  28 + bool get isIPv6 => GetUtils.isIPv6(this);
  29 + bool get isHexadecimal => GetUtils.isHexadecimal(this);
  30 + bool get isPalindrom => GetUtils.isPalindrom(this);
  31 + bool get isPassport => GetUtils.isPassport(this);
  32 + bool get isCurrency => GetUtils.isCurrency(this);
  33 + bool isCpf(String s) => GetUtils.isCpf(this);
  34 + bool isCnpj(String s) => GetUtils.isCnpj(this);
  35 + bool isCaseInsensitiveContains(String b) =>
  36 + GetUtils.isCaseInsensitiveContains(this, b);
  37 + bool isCaseInsensitiveContainsAny(String b) =>
  38 + GetUtils.isCaseInsensitiveContainsAny(this, b);
  39 + String capitalize(String s, {bool firstOnly = false}) =>
  40 + GetUtils.capitalize(this, firstOnly: firstOnly);
  41 + String capitalizeFirst(String s) => GetUtils.capitalizeFirst(this);
  42 + String removeAllWhitespace(String s) => GetUtils.removeAllWhitespace(this);
  43 + String camelCase(String s) => GetUtils.camelCase(this);
  44 + String numericOnly(String s, {bool firstWordOnly = false}) =>
  45 + GetUtils.numericOnly(this, firstWordOnly: firstWordOnly);
  46 +}
  1 +import 'package:flutter/widgets.dart';
  2 +
  3 +extension WidgetPaddingX on Widget {
  4 + Widget paddingAll(double padding) =>
  5 + Padding(padding: EdgeInsets.all(padding), child: this);
  6 +
  7 + Widget paddingSymmetric({double horizontal = 0.0, double vertical = 0.0}) =>
  8 + Padding(
  9 + padding:
  10 + EdgeInsets.symmetric(horizontal: horizontal, vertical: vertical),
  11 + child: this);
  12 +
  13 + Widget paddingOnly({
  14 + double left = 0.0,
  15 + double top = 0.0,
  16 + double right = 0.0,
  17 + double bottom = 0.0,
  18 + }) =>
  19 + Padding(
  20 + padding: EdgeInsets.only(
  21 + top: top, left: left, right: right, bottom: bottom),
  22 + child: this);
  23 +
  24 + Widget get paddingZero => Padding(padding: EdgeInsets.zero, child: this);
  25 +}
  26 +
  27 +extension WidgetMarginX on Widget {
  28 + Widget marginAll(double margin) =>
  29 + Container(margin: EdgeInsets.all(margin), child: this);
  30 +
  31 + Widget marginSymmetric({double horizontal = 0.0, double vertical = 0.0}) =>
  32 + Container(
  33 + margin:
  34 + EdgeInsets.symmetric(horizontal: horizontal, vertical: vertical),
  35 + child: this);
  36 +
  37 + Widget marginOnly({
  38 + double left = 0.0,
  39 + double top = 0.0,
  40 + double right = 0.0,
  41 + double bottom = 0.0,
  42 + }) =>
  43 + Container(
  44 + margin: EdgeInsets.only(
  45 + top: top, left: left, right: right, bottom: bottom),
  46 + child: this);
  47 +
  48 + Widget get marginZero => Container(margin: EdgeInsets.zero, child: this);
  49 +}
1 -import 'package:get/src/utils/regex/regex.dart';  
2 -  
3 class GetUtils { 1 class GetUtils {
4 /// Checks if data is null. 2 /// Checks if data is null.
5 static bool isNull(dynamic s) => s == null; 3 static bool isNull(dynamic s) => s == null;
@@ -27,13 +25,11 @@ class GetUtils { @@ -27,13 +25,11 @@ class GetUtils {
27 } 25 }
28 26
29 /// Checks if string consist only numeric. 27 /// Checks if string consist only numeric.
30 - /// Numeric only doesnt accepting "." which double data type have  
31 - static bool isNumericOnly(String s) =>  
32 - RegexValidation.hasMatch(s, regex.numericOnly); 28 + /// Numeric only doesn't accepting "." which double data type have
  29 + static bool isNumericOnly(String s) => hasMatch(s, r'^\d+$');
33 30
34 /// Checks if string consist only Alphabet. (No Whitespace) 31 /// Checks if string consist only Alphabet. (No Whitespace)
35 - static bool isAlphabetOnly(String s) =>  
36 - RegexValidation.hasMatch(s, regex.alphabetOnly); 32 + static bool isAlphabetOnly(String s) => hasMatch(s, r'^[a-zA-Z]+$');
37 33
38 /// Checks if string is boolean. 34 /// Checks if string is boolean.
39 static bool isBool(String s) { 35 static bool isBool(String s) {
@@ -41,81 +37,133 @@ class GetUtils { @@ -41,81 +37,133 @@ class GetUtils {
41 return (s == 'true' || s == 'false'); 37 return (s == 'true' || s == 'false');
42 } 38 }
43 39
44 - /// Checks if string is an vector file.  
45 - static bool isVector(String s) => RegexValidation.hasMatch(s, regex.vector); 40 + /// Checks if string is an video file.
  41 + static bool isVideo(String filePath) {
  42 + String ext = filePath.toLowerCase();
  43 + return (((((ext.endsWith(".mp4") || ext.endsWith(".avi")) ||
  44 + ext.endsWith(".wmv")) ||
  45 + ext.endsWith(".rmvb")) ||
  46 + ext.endsWith(".mpg")) ||
  47 + ext.endsWith(".mpeg")) ||
  48 + ext.endsWith(".3gp");
  49 + }
46 50
47 /// Checks if string is an image file. 51 /// Checks if string is an image file.
48 - static bool isImage(String s) => RegexValidation.hasMatch(s, regex.image); 52 + static bool isImage(String filePath) {
  53 + String ext = filePath.toLowerCase();
  54 + return (((ext.endsWith(".jpg") || ext.endsWith(".jpeg")) ||
  55 + ext.endsWith(".png")) ||
  56 + ext.endsWith(".gif")) ||
  57 + ext.endsWith(".bmp");
  58 + }
49 59
50 /// Checks if string is an audio file. 60 /// Checks if string is an audio file.
51 - static bool isAudio(String s) => RegexValidation.hasMatch(s, regex.audio); 61 + static bool isAudio(String filePath) {
  62 + String ext = filePath.toLowerCase();
  63 + return (((ext.endsWith(".mp3") || ext.endsWith(".wav")) ||
  64 + ext.endsWith(".wma")) ||
  65 + ext.endsWith(".amr")) ||
  66 + ext.endsWith(".ogg");
  67 + }
52 68
53 - /// Checks if string is an video file.  
54 - static bool isVideo(String s) => RegexValidation.hasMatch(s, regex.video); 69 + /// Checks if string is an powerpoint file.
  70 + static bool isPPT(String filePath) {
  71 + String ext = filePath.toLowerCase();
  72 + return ext.endsWith(".ppt") || ext.endsWith(".pptx");
  73 + }
55 74
56 - /// Checks if string is an txt file.  
57 - static bool isTxt(String s) => RegexValidation.hasMatch(s, regex.txt); 75 + /// Checks if string is an word file.
  76 + static bool isWord(String filePath) {
  77 + String ext = filePath.toLowerCase();
  78 + return ext.endsWith(".doc") || ext.endsWith(".docx");
  79 + }
58 80
59 - /// Checks if string is an Doc file.  
60 - static bool isDocument(String s) => RegexValidation.hasMatch(s, regex.doc); 81 + /// Checks if string is an excel file.
  82 + static bool isExcel(String filePath) {
  83 + String ext = filePath.toLowerCase();
  84 + return ext.endsWith(".xls") || ext.endsWith(".xlsx");
  85 + }
61 86
62 - /// Checks if string is an Excel file.  
63 - static bool isExcel(String s) => RegexValidation.hasMatch(s, regex.excel); 87 + /// Checks if string is an apk file.
  88 + static bool isAPK(String filePath) {
  89 + return filePath.toLowerCase().endsWith(".apk");
  90 + }
64 91
65 - /// Checks if string is an PPT file.  
66 - static bool isPPT(String s) => RegexValidation.hasMatch(s, regex.ppt); 92 + /// Checks if string is an pdf file.
  93 + static bool isPDF(String filePath) {
  94 + return filePath.toLowerCase().endsWith(".pdf");
  95 + }
67 96
68 - /// Checks if string is an APK file.  
69 - static bool isAPK(String s) => RegexValidation.hasMatch(s, regex.apk); 97 + /// Checks if string is an txt file.
  98 + static bool isTxt(String filePath) {
  99 + return filePath.toLowerCase().endsWith(".txt");
  100 + }
70 101
71 - /// Checks if string is an video file.  
72 - static bool isPDF(String s) => RegexValidation.hasMatch(s, regex.pdf); 102 + /// Checks if string is an chm file.
  103 + static bool isChm(String filePath) {
  104 + return filePath.toLowerCase().endsWith(".chm");
  105 + }
73 106
74 - /// Checks if string is an HTML file.  
75 - static bool isHTML(String s) => RegexValidation.hasMatch(s, regex.html); 107 + /// Checks if string is a vector file.
  108 + static bool isVector(String filePath) {
  109 + return filePath.toLowerCase().endsWith(".svg");
  110 + }
  111 +
  112 + /// Checks if string is an html file.
  113 + static bool isHTML(String filePath) {
  114 + return filePath.toLowerCase().endsWith(".html");
  115 + }
  116 +
  117 + /// Checks if string is a valid username.
  118 + static bool isUsername(String s) =>
  119 + hasMatch(s, r'^[a-zA-Z0-9][a-zA-Z0-9_.]+[a-zA-Z0-9]$');
76 120
77 /// Checks if string is URL. 121 /// Checks if string is URL.
78 - static bool isURL(String s) => RegexValidation.hasMatch(s, regex.url); 122 + static bool isURL(String s) => hasMatch(s,
  123 + r"^((((H|h)(T|t)|(F|f))(T|t)(P|p)((S|s)?))\://)?(www.|[a-zA-Z0-9].)[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,6}(\:[0-9]{1,5})*(/($|[a-zA-Z0-9\.\,\;\?\'\\\+&amp;%\$#\=~_\-]+))*$");
79 124
80 /// Checks if string is email. 125 /// Checks if string is email.
81 - static bool isEmail(String s) => RegexValidation.hasMatch(s, regex.email); 126 + static bool isEmail(String s) => hasMatch(s,
  127 + r'^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$');
82 128
83 /// Checks if string is phone number. 129 /// Checks if string is phone number.
84 - static bool isPhoneNumber(String s) =>  
85 - RegexValidation.hasMatch(s, regex.phone); 130 + static bool isPhoneNumber(String s) => hasMatch(s,
  131 + r'^(0|\+|(\+[0-9]{2,4}|\(\+?[0-9]{2,4}\)) ?)([0-9]*|\d{2,4}-\d{2,4}(-\d{2,4})?)$');
86 132
87 /// Checks if string is DateTime (UTC or Iso8601). 133 /// Checks if string is DateTime (UTC or Iso8601).
88 static bool isDateTime(String s) => 134 static bool isDateTime(String s) =>
89 - RegexValidation.hasMatch(s, regex.basicDateTime); 135 + hasMatch(s, r'^\d{4}-\d{2}-\d{2}[ T]\d{2}:\d{2}:\d{2}.\d{3}Z?$');
90 136
91 /// Checks if string is MD5 hash. 137 /// Checks if string is MD5 hash.
92 - static bool isMD5(String s) => RegexValidation.hasMatch(s, regex.md5); 138 + static bool isMD5(String s) => hasMatch(s, r'^[a-f0-9]{32}$');
93 139
94 /// Checks if string is SHA1 hash. 140 /// Checks if string is SHA1 hash.
95 - static bool isSHA1(String s) => RegexValidation.hasMatch(s, regex.sha1); 141 + static bool isSHA1(String s) =>
  142 + hasMatch(s, r'(([A-Fa-f0-9]{2}\:){19}[A-Fa-f0-9]{2}|[A-Fa-f0-9]{40})');
96 143
97 /// Checks if string is SHA256 hash. 144 /// Checks if string is SHA256 hash.
98 - static bool isSHA256(String s) => RegexValidation.hasMatch(s, regex.sha256);  
99 -  
100 - /// Checks if string is ISBN 10 or 13.  
101 - static bool isISBN(String s) => RegexValidation.hasMatch(s, regex.isbn); 145 + static bool isSHA256(String s) =>
  146 + hasMatch(s, r'([A-Fa-f0-9]{2}\:){31}[A-Fa-f0-9]{2}|[A-Fa-f0-9]{64}');
102 147
103 /// Checks if string is SSN (Social Security Number). 148 /// Checks if string is SSN (Social Security Number).
104 - static bool isSSN(String s) => RegexValidation.hasMatch(s, regex.ssn); 149 + static bool isSSN(String s) => hasMatch(s,
  150 + r'^(?!0{3}|6{3}|9[0-9]{2})[0-9]{3}-?(?!0{2})[0-9]{2}-?(?!0{4})[0-9]{4}$');
105 151
106 /// Checks if string is binary. 152 /// Checks if string is binary.
107 - static bool isBinary(String s) => RegexValidation.hasMatch(s, regex.binary); 153 + static bool isBinary(String s) => hasMatch(s, r'^[0-1]*$');
108 154
109 /// Checks if string is IPv4. 155 /// Checks if string is IPv4.
110 - static bool isIPv4(String s) => RegexValidation.hasMatch(s, regex.ipv4); 156 + static bool isIPv4(String s) =>
  157 + hasMatch(s, r'^(?:(?:^|\.)(?:2(?:5[0-5]|[0-4]\d)|1?\d?\d)){4}$');
111 158
112 /// Checks if string is IPv6. 159 /// Checks if string is IPv6.
113 - static bool isIPv6(String s) => RegexValidation.hasMatch(s, regex.ipv6); 160 + static bool isIPv6(String s) => hasMatch(s,
  161 + r'^((([0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}:[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){5}:([0-9A-Fa-f]{1,4}:)?[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){4}:([0-9A-Fa-f]{1,4}:){0,2}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){3}:([0-9A-Fa-f]{1,4}:){0,3}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){2}:([0-9A-Fa-f]{1,4}:){0,4}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(([0-9A-Fa-f]{1,4}:){0,5}:((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(::([0-9A-Fa-f]{1,4}:){0,5}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|([0-9A-Fa-f]{1,4}::([0-9A-Fa-f]{1,4}:){0,5}[0-9A-Fa-f]{1,4})|(::([0-9A-Fa-f]{1,4}:){0,6}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){1,7}:))$');
114 162
115 /// Checks if string is hexadecimal. 163 /// Checks if string is hexadecimal.
116 /// Example: HexColor => #12F 164 /// Example: HexColor => #12F
117 static bool isHexadecimal(String s) => 165 static bool isHexadecimal(String s) =>
118 - RegexValidation.hasMatch(s, regex.hexadecimal); 166 + hasMatch(s, r'^#?([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$');
119 167
120 /// Checks if string is Palindrom. 168 /// Checks if string is Palindrom.
121 static bool isPalindrom(String s) { 169 static bool isPalindrom(String s) {
@@ -151,11 +199,11 @@ class GetUtils { @@ -151,11 +199,11 @@ class GetUtils {
151 199
152 /// Checks if string is Passport No. 200 /// Checks if string is Passport No.
153 static bool isPassport(String s) => 201 static bool isPassport(String s) =>
154 - RegexValidation.hasMatch(s, regex.passport); 202 + hasMatch(s, r'^(?!^0+$)[a-zA-Z0-9]{6,9}$');
155 203
156 /// Checks if string is Currency. 204 /// Checks if string is Currency.
157 - static bool isCurrency(String s) =>  
158 - RegexValidation.hasMatch(s, regex.currency); 205 + static bool isCurrency(String s) => hasMatch(s,
  206 + r'^(S?\$|\₩|Rp|\¥|\€|\₹|\₽|fr|R$|R)?[ ]?[-]?([0-9]{1,3}[,.]([0-9]{3}[,.])*[0-9]{3}|[0-9]+)([,.][0-9]{1,2})?( ?(USD?|AUD|NZD|CAD|CHF|GBP|CNY|EUR|JPY|IDR|MXN|NOK|KRW|TRY|INR|RUB|BRL|ZAR|SGD|MYR))?$');
159 207
160 /// Checks if length of data is LOWER than maxLength. 208 /// Checks if length of data is LOWER than maxLength.
161 static bool isLengthLowerThan(dynamic s, int maxLength) { 209 static bool isLengthLowerThan(dynamic s, int maxLength) {
@@ -425,11 +473,6 @@ class GetUtils { @@ -425,11 +473,6 @@ class GetUtils {
425 return numericOnlyStr; 473 return numericOnlyStr;
426 } 474 }
427 475
428 - static Regex regex = Regex();  
429 -}  
430 -  
431 -class RegexValidation {  
432 - /// Returns whether the pattern has a match in the string [input].  
433 static bool hasMatch(String s, Pattern p) => 476 static bool hasMatch(String s, Pattern p) =>
434 (s == null) ? false : RegExp(p).hasMatch(s); 477 (s == null) ? false : RegExp(p).hasMatch(s);
435 } 478 }
@@ -10,7 +10,7 @@ extension GetStringUtils on String { @@ -10,7 +10,7 @@ extension GetStringUtils on String {
10 bool get isAudioFileName => GetUtils.isAudio(this); 10 bool get isAudioFileName => GetUtils.isAudio(this);
11 bool get isVideoFileName => GetUtils.isVideo(this); 11 bool get isVideoFileName => GetUtils.isVideo(this);
12 bool get isTxtFileName => GetUtils.isTxt(this); 12 bool get isTxtFileName => GetUtils.isTxt(this);
13 - bool get isDocumentFileName => GetUtils.isDocument(this); 13 + bool get isDocumentFileName => GetUtils.isWord(this);
14 bool get isExcelFileName => GetUtils.isExcel(this); 14 bool get isExcelFileName => GetUtils.isExcel(this);
15 bool get isPPTFileName => GetUtils.isPPT(this); 15 bool get isPPTFileName => GetUtils.isPPT(this);
16 bool get isAPKFileName => GetUtils.isAPK(this); 16 bool get isAPKFileName => GetUtils.isAPK(this);
@@ -23,7 +23,6 @@ extension GetStringUtils on String { @@ -23,7 +23,6 @@ extension GetStringUtils on String {
23 bool get isMD5 => GetUtils.isMD5(this); 23 bool get isMD5 => GetUtils.isMD5(this);
24 bool get isSHA1 => GetUtils.isSHA1(this); 24 bool get isSHA1 => GetUtils.isSHA1(this);
25 bool get isSHA256 => GetUtils.isSHA256(this); 25 bool get isSHA256 => GetUtils.isSHA256(this);
26 - bool get isISBN => GetUtils.isISBN(this);  
27 bool get isBinary => GetUtils.isBinary(this); 26 bool get isBinary => GetUtils.isBinary(this);
28 bool get isIPv4 => GetUtils.isIPv4(this); 27 bool get isIPv4 => GetUtils.isIPv4(this);
29 bool get isIPv6 => GetUtils.isIPv6(this); 28 bool get isIPv6 => GetUtils.isIPv6(this);
@@ -53,22 +52,6 @@ extension GetNumUtils on num { @@ -53,22 +52,6 @@ extension GetNumUtils on num {
53 } 52 }
54 53
55 extension GetDynamicUtils on dynamic { 54 extension GetDynamicUtils on dynamic {
56 - /// It's This is overloading the IDE's options. Only the most useful and popular options will stay here.  
57 -  
58 bool get isNull => GetUtils.isNull(this); 55 bool get isNull => GetUtils.isNull(this);
59 bool get isNullOrBlank => GetUtils.isNullOrBlank(this); 56 bool get isNullOrBlank => GetUtils.isNullOrBlank(this);
60 -  
61 - // bool get isOneAKind => GetUtils.isOneAKind(this);  
62 - // bool isLengthLowerThan(int maxLength) =>  
63 - // GetUtils.isLengthLowerThan(this, maxLength);  
64 - // bool isLengthGreaterThan(int maxLength) =>  
65 - // GetUtils.isLengthGreaterThan(this, maxLength);  
66 - // bool isLengthGreaterOrEqual(int maxLength) =>  
67 - // GetUtils.isLengthGreaterOrEqual(this, maxLength);  
68 - // bool isLengthLowerOrEqual(int maxLength) =>  
69 - // GetUtils.isLengthLowerOrEqual(this, maxLength);  
70 - // bool isLengthEqualTo(int maxLength) =>  
71 - // GetUtils.isLengthEqualTo(this, maxLength);  
72 - // bool isLengthBetween(int minLength, int maxLength) =>  
73 - // GetUtils.isLengthBetween(this, minLength, maxLength);  
74 } 57 }
1 -class Regex {  
2 - /// Username regex  
3 - Pattern username = r'^[a-zA-Z0-9][a-zA-Z0-9_.]+[a-zA-Z0-9]$';  
4 -  
5 - /// Email regex  
6 - Pattern email =  
7 - r'^[a-z0-9]+([-+._][a-z0-9]+){0,2}@.*?(\.(a(?:[cdefgilmnoqrstuwxz]|ero|(?:rp|si)a)|b(?:[abdefghijmnorstvwyz]iz)|c(?:[acdfghiklmnoruvxyz]|at|o(?:m|op))|d[ejkmoz]|e(?:[ceghrstu]|du)|f[ijkmor]|g(?:[abdefghilmnpqrstuwy]|ov)|h[kmnrtu]|i(?:[delmnoqrst]|n(?:fo|t))|j(?:[emop]|obs)|k[eghimnprwyz]|l[abcikrstuvy]|m(?:[acdeghklmnopqrstuvwxyz]|il|obi|useum)|n(?:[acefgilopruz]|ame|et)|o(?:m|rg)|p(?:[aefghklmnrstwy]|ro)|qa|r[eosuw]|s[abcdeghijklmnortuvyz]|t(?:[cdfghjklmnoprtvwz]|(?:rav)?el)|u[agkmsyz]|v[aceginu]|w[fs]|y[etu]|z[amw])\b){1,2}$';  
8 -  
9 - /// URL regex  
10 - Pattern url =  
11 - r"^((((H|h)(T|t)|(F|f))(T|t)(P|p)((S|s)?))\://)?(www.|[a-zA-Z0-9].)[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,6}(\:[0-9]{1,5})*(/($|[a-zA-Z0-9\.\,\;\?\'\\\+&amp;%\$#\=~_\-]+))*$";  
12 -  
13 - /// Phone Number regex  
14 - /// Must started by either, "0", "+", "+XX <X between 2 to 4 digit>", "(+XX <X between 2 to 3 digit>)"  
15 - /// Can add whitespace separating digit with "+" or "(+XX)"  
16 - /// Example: 05555555555, +555 5555555555, (+123) 5555555555, (555) 5555555555, +5555 5555555555  
17 - Pattern phone =  
18 - r'^(0|\+|(\+[0-9]{2,4}|\(\+?[0-9]{2,4}\)) ?)([0-9]*|\d{2,4}-\d{2,4}(-\d{2,4})?)$';  
19 -  
20 - /// Hexadecimal regex  
21 - Pattern hexadecimal = r'^#?([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$';  
22 -  
23 - /// Image vector regex  
24 - Pattern vector = r'.(svg)$';  
25 -  
26 - /// Image regex  
27 - Pattern image = r'.(jpeg|jpg|gif|png|bmp)$';  
28 -  
29 - /// Audio regex  
30 - Pattern audio = r'.(mp3|wav|wma|amr|ogg)$';  
31 -  
32 - /// Video regex  
33 - Pattern video = r'.(mp4|avi|wmv|rmvb|mpg|mpeg|3gp)$';  
34 -  
35 - /// Txt regex  
36 - Pattern txt = r'.txt$';  
37 -  
38 - /// Document regex  
39 - Pattern doc = r'.(doc|docx)$';  
40 -  
41 - /// Excel regex  
42 - Pattern excel = r'.(xls|xlsx)$';  
43 -  
44 - /// PPT regex  
45 - Pattern ppt = r'.(ppt|pptx)$';  
46 -  
47 - /// Document regex  
48 - Pattern apk = r'.apk$';  
49 -  
50 - /// PDF regex  
51 - Pattern pdf = r'.pdf$';  
52 -  
53 - /// HTML regex  
54 - Pattern html = r'.html$';  
55 -  
56 - /// DateTime regex (UTC)  
57 - /// Unformatted date time (UTC and Iso8601)  
58 - /// Example: 2020-04-27 08:14:39.977, 2020-04-27T08:14:39.977, 2020-04-27 01:14:39.977Z  
59 - Pattern basicDateTime = r'^\d{4}-\d{2}-\d{2}[ T]\d{2}:\d{2}:\d{2}.\d{3}Z?$';  
60 -  
61 - /// Binary regex  
62 - /// Consist only 0 & 1  
63 - Pattern binary = r'^[0-1]*$';  
64 -  
65 - /// MD5 regex  
66 - Pattern md5 = r'^[a-f0-9]{32}$';  
67 -  
68 - /// SHA1 regex  
69 - Pattern sha1 = r'(([A-Fa-f0-9]{2}\:){19}[A-Fa-f0-9]{2}|[A-Fa-f0-9]{40})';  
70 -  
71 - /// SHA256 regex  
72 - Pattern sha256 = r'([A-Fa-f0-9]{2}\:){31}[A-Fa-f0-9]{2}|[A-Fa-f0-9]{64}';  
73 -  
74 - /// SSN (Social Security Number) regex  
75 - Pattern ssn =  
76 - r'^(?!0{3}|6{3}|9[0-9]{2})[0-9]{3}-?(?!0{2})[0-9]{2}-?(?!0{4})[0-9]{4}$';  
77 -  
78 - /// IPv4 regex  
79 - Pattern ipv4 = r'^(?:(?:^|\.)(?:2(?:5[0-5]|[0-4]\d)|1?\d?\d)){4}$';  
80 -  
81 - /// IPv6 regex  
82 - Pattern ipv6 =  
83 - r'^((([0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}:[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){5}:([0-9A-Fa-f]{1,4}:)?[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){4}:([0-9A-Fa-f]{1,4}:){0,2}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){3}:([0-9A-Fa-f]{1,4}:){0,3}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){2}:([0-9A-Fa-f]{1,4}:){0,4}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(([0-9A-Fa-f]{1,4}:){0,5}:((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(::([0-9A-Fa-f]{1,4}:){0,5}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|([0-9A-Fa-f]{1,4}::([0-9A-Fa-f]{1,4}:){0,5}[0-9A-Fa-f]{1,4})|(::([0-9A-Fa-f]{1,4}:){0,6}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){1,7}:))$';  
84 -  
85 - /// ISBN 10 & 13 regex  
86 - Pattern isbn =  
87 - r'(ISBN(\-1[03])?[:]?[ ]?)?(([0-9Xx][- ]?){13}|([0-9Xx][- ]?){10})';  
88 -  
89 - /// Passport No. regex  
90 - Pattern passport = r'^(?!^0+$)[a-zA-Z0-9]{6,9}$';  
91 -  
92 - /// Currency regex  
93 - Pattern currency =  
94 - r'^(S?\$|\₩|Rp|\¥|\€|\₹|\₽|fr|R$|R)?[ ]?[-]?([0-9]{1,3}[,.]([0-9]{3}[,.])*[0-9]{3}|[0-9]+)([,.][0-9]{1,2})?( ?(USD?|AUD|NZD|CAD|CHF|GBP|CNY|EUR|JPY|IDR|MXN|NOK|KRW|TRY|INR|RUB|BRL|ZAR|SGD|MYR))?$';  
95 -  
96 - /// Numeric Only regex (No Whitespace & Symbols)  
97 - Pattern numericOnly = r'^\d+$';  
98 -  
99 - /// Alphabet Only regex (No Whitespace & Symbols)  
100 - Pattern alphabetOnly = r'^[a-zA-Z]+$';  
101 -  
102 - /// Password (Easy) Regex  
103 - /// Allowing all character except 'whitespace'  
104 - /// Minimum character: 8  
105 - Pattern passwordEasy = r'^\S{8,}$';  
106 -  
107 - /// Password (Easy) Regex  
108 - /// Allowing all character  
109 - /// Minimum character: 8  
110 - Pattern passwordEasyAllowedWhitespace = r'^[\S ]{8,}$';  
111 -  
112 - /// Password (Normal) Regex  
113 - /// Allowing all character except 'whitespace'  
114 - /// Must contains at least: 1 letter & 1 number  
115 - /// Minimum character: 8  
116 - Pattern passwordNormal1 = r'^(?=.*[A-Za-z])(?=.*\d)\S{8,}$';  
117 -  
118 - /// Password (Normal) Regex  
119 - /// Allowing all character  
120 - /// Must contains at least: 1 letter & 1 number  
121 - /// Minimum character: 8  
122 - Pattern passwordNormal1AllowedWhitespace =  
123 - r'^(?=.*[A-Za-z])(?=.*\d)[\S ]{8,}$';  
124 -  
125 - /// Password (Normal) Regex  
126 - /// Allowing LETTER and NUMBER only  
127 - /// Must contains at least: 1 letter & 1 number  
128 - /// Minimum character: 8  
129 - Pattern passwordNormal2 = r'^(?=.*[A-Za-z])(?=.*\d)[a-zA-Z0-9]{8,}$';  
130 -  
131 - /// Password (Normal) Regex  
132 - /// Allowing LETTER and NUMBER only  
133 - /// Must contains: 1 letter & 1 number  
134 - /// Minimum character: 8  
135 - Pattern passwordNormal2AllowedWhitespace =  
136 - r'^(?=.*[A-Za-z])(?=.*\d)[a-zA-Z0-9 ]{8,}$';  
137 -  
138 - /// Password (Normal) Regex  
139 - /// Allowing all character except 'whitespace'  
140 - /// Must contains at least: 1 uppercase letter, 1 lowecase letter & 1 number  
141 - /// Minimum character: 8  
142 - Pattern passwordNormal3 = r'^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)\S{8,}$';  
143 -  
144 - /// Password (Normal) Regex  
145 - /// Allowing all character  
146 - /// Must contains at least: 1 uppercase letter, 1 lowecase letter & 1 number  
147 - /// Minimum character: 8  
148 - Pattern passwordNormal3AllowedWhitespace =  
149 - r'^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[\S ]{8,}$';  
150 -  
151 - /// Password (Hard) Regex  
152 - /// Allowing all character except 'whitespace'  
153 - /// Must contains at least: 1 uppercase letter, 1 lowecase letter, 1 number, & 1 special character (symbol)  
154 - /// Minimum character: 8  
155 - Pattern passwordHard = r'^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[\W_])\S{8,}$';  
156 -  
157 - /// Password (Hard) Regex  
158 - /// Allowing all character  
159 - /// Must contains at least: 1 uppercase letter, 1 lowecase letter, 1 number, & 1 special character (symbol)  
160 - /// Minimum character: 8  
161 - Pattern passwordHardAllowedWhitespace =  
162 - r'^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[\W_])[\S ]{8,}$';  
163 -}  
1 -export 'src/utils/context_extensions/extensions.dart'; 1 +export 'src/utils/extensions/export.dart';
2 export 'src/utils/queue/get_queue.dart'; 2 export 'src/utils/queue/get_queue.dart';
3 export 'src/utils/platform/platform.dart'; 3 export 'src/utils/platform/platform.dart';
4 export 'src/utils/regex/get_utils.dart'; 4 export 'src/utils/regex/get_utils.dart';
5 -export 'src/utils/regex/get_utils_extensions.dart';  
@@ -33,7 +33,7 @@ void main() { @@ -33,7 +33,7 @@ void main() {
33 child: Text("increment"), 33 child: Text("increment"),
34 onPressed: () => controller.increment(), 34 onPressed: () => controller.increment(),
35 ), 35 ),
36 - obx(() => Text( 36 + Obx(() => Text(
37 'Obx: ${controller.map.value.length}', 37 'Obx: ${controller.map.value.length}',
38 )) 38 ))
39 ]), 39 ]),
  1 +import 'package:flutter_test/flutter_test.dart';
  2 +
  3 +void main() {
  4 + test('', () {});
  5 +}
  1 +import 'package:flutter_test/flutter_test.dart';
  2 +import 'package:get/utils.dart';
  3 +
  4 +void main() {
  5 + test('Test for toPrecision on Double', () {
  6 + double testVar = 5.4545454;
  7 + expect(testVar.toPrecision(2), equals(5.45));
  8 + });
  9 +}
  1 +import 'package:flutter_test/flutter_test.dart';
  2 +
  3 +void main() {
  4 + test('', () {});
  5 +}
  1 +import 'package:flutter_test/flutter_test.dart';
  2 +import 'package:get/utils.dart';
  3 +
  4 +void main() {
  5 + num x = 5;
  6 + num y = 7;
  7 + test('Test for var.isLowerThan(value)', () {
  8 + expect(x.isLowerThan(y), true);
  9 + expect(y.isLowerThan(x), false);
  10 + });
  11 + test('Test for var.isGreaterThan(value)', () {
  12 + expect(x.isGreaterThan(y), false);
  13 + expect(y.isGreaterThan(x), true);
  14 + });
  15 + test('Test for var.isGreaterThan(value)', () {
  16 + expect(x.isEqual(y), false);
  17 + expect(y.isEqual(x), false);
  18 + expect(x.isEqual(5), true);
  19 + expect(y.isEqual(7), true);
  20 + });
  21 +}
  1 +import 'package:flutter_test/flutter_test.dart';
  2 +import 'package:get/utils.dart';
  3 +
  4 +void main() {
  5 + group('Test group for extension: isNullOrBlank', () {
  6 + String testString;
  7 + test('String extension: isNullOrBlank', () {
  8 + expect(testString.isNullOrBlank, equals(true));
  9 + });
  10 + test('String extension: isNullOrBlank', () {
  11 + testString = 'Not null anymore';
  12 + expect(testString.isNullOrBlank, equals(false));
  13 + });
  14 + test('String extension: isNullOrBlank', () {
  15 + testString = '';
  16 + expect(testString.isNullOrBlank, equals(true));
  17 + });
  18 + });
  19 +}
  1 +import 'package:flutter/widgets.dart';
  2 +import 'package:flutter_test/flutter_test.dart';
  3 +import 'package:get/utils.dart';
  4 +
  5 +void main() {
  6 + group('Group test for PaddingX Extension', () {
  7 + testWidgets('Test of paddingAll', (WidgetTester tester) async {
  8 + Widget containerTest;
  9 +
  10 + expect(find.byType(Padding), findsNothing);
  11 +
  12 + await tester.pumpWidget(containerTest.paddingAll(16));
  13 +
  14 + expect(find.byType(Padding), findsOneWidget);
  15 + });
  16 +
  17 + testWidgets('Test of paddingOnly', (WidgetTester tester) async {
  18 + Widget containerTest;
  19 +
  20 + expect(find.byType(Padding), findsNothing);
  21 +
  22 + await tester.pumpWidget(containerTest.paddingOnly(top: 16));
  23 +
  24 + expect(find.byType(Padding), findsOneWidget);
  25 + });
  26 +
  27 + testWidgets('Test of paddingSymmetric', (WidgetTester tester) async {
  28 + Widget containerTest;
  29 +
  30 + expect(find.byType(Padding), findsNothing);
  31 +
  32 + await tester.pumpWidget(containerTest.paddingSymmetric(vertical: 16));
  33 +
  34 + expect(find.byType(Padding), findsOneWidget);
  35 + });
  36 +
  37 + testWidgets('Test of paddingZero', (WidgetTester tester) async {
  38 + Widget containerTest;
  39 +
  40 + expect(find.byType(Padding), findsNothing);
  41 +
  42 + await tester.pumpWidget(containerTest.paddingZero);
  43 +
  44 + expect(find.byType(Padding), findsOneWidget);
  45 + });
  46 + });
  47 +
  48 + group('Group test for MarginX Extension', () {
  49 + testWidgets('Test of marginAll', (WidgetTester tester) async {
  50 + Widget containerTest;
  51 +
  52 + await tester.pumpWidget(containerTest.marginAll(16));
  53 +
  54 + expect(find.byType(Container), findsOneWidget);
  55 + });
  56 +
  57 + testWidgets('Test of marginOnly', (WidgetTester tester) async {
  58 + Widget containerTest;
  59 +
  60 + await tester.pumpWidget(containerTest.marginOnly(top: 16));
  61 +
  62 + expect(find.byType(Container), findsOneWidget);
  63 + });
  64 +
  65 + testWidgets('Test of marginSymmetric', (WidgetTester tester) async {
  66 + Widget containerTest;
  67 +
  68 + await tester.pumpWidget(containerTest.marginSymmetric(vertical: 16));
  69 +
  70 + expect(find.byType(Container), findsOneWidget);
  71 + });
  72 +
  73 + testWidgets('Test of marginZero', (WidgetTester tester) async {
  74 + Widget containerTest;
  75 +
  76 + await tester.pumpWidget(containerTest.marginZero);
  77 +
  78 + expect(find.byType(Container), findsOneWidget);
  79 + });
  80 + });
  81 +}