Committed by
GitHub
Merge pull request #591 from MrOlolo/fix/null-or-blank_function
fix isNullOrBlank function
Showing
1 changed file
with
4 additions
and
9 deletions
| @@ -14,15 +14,10 @@ class GetUtils { | @@ -14,15 +14,10 @@ class GetUtils { | ||
| 14 | static bool isNullOrBlank(dynamic s) { | 14 | static bool isNullOrBlank(dynamic s) { | 
| 15 | if (isNull(s)) return true; | 15 | if (isNull(s)) return true; | 
| 16 | 16 | ||
| 17 | - switch (s.runtimeType as Type) { | ||
| 18 | - case String: | ||
| 19 | - case List: | ||
| 20 | - case Map: | ||
| 21 | - case Set: | ||
| 22 | - case Iterable: | ||
| 23 | - return s.isEmpty as bool; | ||
| 24 | - default: | ||
| 25 | - return s.toString() == 'null' || s.toString().trim().isEmpty; | 17 | + if (s is String || s is List || s is Map || s is Set || s is Iterable) { | 
| 18 | + return s.isEmpty as bool; | ||
| 19 | + } else { | ||
| 20 | + return s.toString() == 'null' || s.toString().trim().isEmpty; | ||
| 26 | } | 21 | } | 
| 27 | } | 22 | } | 
| 28 | 23 | 
- 
Please register or login to post a comment