Toggle navigation
Toggle navigation
This project
Loading...
Sign in
flutter_package
/
fluttertpc_get
Go to a project
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
Jonny Borges
2020-09-15 12:36:53 -0300
Browse Files
Options
Browse Files
Download
Plain Diff
Committed by
GitHub
2020-09-15 12:36:53 -0300
Commit
5264765bc81c0e67188bdd4cb1a42840c447c37a
5264765b
2 parents
39f04062
b7064d2c
Merge pull request #612 from unacorbatanegra/master
PrintExtensions
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
51 additions
and
0 deletions
lib/src/utils/extensions/dynamic_extensions.dart
lib/src/utils/regex/get_utils.dart
test/src/extensions/dynamic_extensions_test.dart
lib/src/utils/extensions/dynamic_extensions.dart
View file @
5264765
import
'../../../utils.dart'
;
import
'../regex/get_utils.dart'
;
extension
GetDynamicUtils
on
dynamic
{
bool
get
isNull
=>
GetUtils
.
isNull
(
this
);
bool
get
isNullOrBlank
=>
GetUtils
.
isNullOrBlank
(
this
);
void
printError
(
{
String
info
=
''
,
Function
logFunction
=
GetUtils
.
printFunction
})
=>
logFunction
(
'Error:
${this.runtimeType}
'
,
this
,
info
,
isError:
true
);
void
printInfo
(
{
String
info
=
''
,
Function
printFunction
=
GetUtils
.
printFunction
})
=>
printFunction
(
'Info:
${this.runtimeType}
'
,
this
,
info
);
}
...
...
lib/src/utils/regex/get_utils.dart
View file @
5264765
import
'../../../get.dart'
;
class
GetUtils
{
/// Checks if data is null.
static
bool
isNull
(
dynamic
s
)
=>
s
==
null
;
...
...
@@ -492,4 +494,8 @@ class GetUtils {
static
bool
hasMatch
(
String
value
,
String
pattern
)
{
return
(
value
==
null
)
?
false
:
RegExp
(
pattern
).
hasMatch
(
value
);
}
static
void
printFunction
(
String
prefix
,
dynamic
value
,
String
info
,
{
bool
isError
=
false
})
=>
GetConfig
.
log
(
'
$prefix
$value
$info
'
.
trim
(),
isError:
isError
);
}
...
...
test/src/extensions/dynamic_extensions_test.dart
View file @
5264765
...
...
@@ -64,4 +64,39 @@ void main() {
expect
(
EmptyClass
().
isNullOrBlank
,
equals
(
false
));
});
});
test
(
'String test'
,
()
{
var
value
=
'string'
;
var
expected
=
''
;
void
logFunction
(
String
prefix
,
dynamic
value
,
String
info
,
{
bool
isError
=
false
})
{
print
(
'algo'
);
expected
=
'
$prefix
$value
$info
'
.
trim
();
}
value
.
printError
(
logFunction:
logFunction
);
expect
(
expected
,
'Error: String string'
);
});
test
(
'Int test'
,
()
{
var
value
=
1
;
var
expected
=
''
;
void
logFunction
(
String
prefix
,
dynamic
value
,
String
info
,
{
bool
isError
=
false
})
{
expected
=
'
$prefix
$value
$info
'
.
trim
();
}
value
.
printError
(
logFunction:
logFunction
);
expect
(
expected
,
'Error: int 1'
);
});
test
(
'Double test'
,
()
{
var
value
=
1.0
;
var
expected
=
''
;
void
logFunction
(
String
prefix
,
dynamic
value
,
String
info
,
{
bool
isError
=
false
})
{
expected
=
'
$prefix
$value
$info
'
.
trim
();
}
value
.
printError
(
logFunction:
logFunction
);
expect
(
expected
,
'Error: double 1.0'
);
});
}
...
...
Please
register
or
login
to post a comment