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
Nicolas Lopez
2020-09-15 11:12:16 -0400
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
dc9f9d7f7b24e6258ad286ebe5660aed41a21cd0
dc9f9d7f
1 parent
a5d1d77d
printInfo&&Error extension && Test
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
43 additions
and
7 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 @
dc9f9d7
...
...
@@ -9,9 +9,12 @@ extension GetDynamicUtils on dynamic {
bool
get
isNullOrBlank
=>
GetUtils
.
isNullOrBlank
(
this
);
void
logError
({
String
info
=
''
})
=>
GetUtils
.
log
(
'Error:
${this.runtimeType}
'
,
this
,
info
);
void
printError
(
{
String
info
=
''
,
Function
logFunction
=
GetUtils
.
printFunction
})
=>
logFunction
(
'Error:
${this.runtimeType}
'
,
this
,
info
);
void
logInfo
({
String
info
=
''
})
=>
GetUtils
.
log
(
'Info:
${this.runtimeType}
'
,
this
,
info
);
void
printInfo
(
{
String
info
=
''
,
Function
printFunction
=
GetUtils
.
printFunction
})
=>
printFunction
(
'Info:
${this.runtimeType}
'
,
this
,
info
);
}
...
...
lib/src/utils/regex/get_utils.dart
View file @
dc9f9d7
...
...
@@ -485,6 +485,6 @@ class GetUtils {
return
(
value
==
null
)
?
false
:
RegExp
(
pattern
).
hasMatch
(
value
);
}
static
void
log
(
String
prefix
,
dynamic
value
,
String
info
)
=>
print
(
'
$prefix
$value
$info
'
);
static
void
printFunction
(
String
prefix
,
dynamic
value
,
String
info
)
=>
print
(
'
$prefix
$value
$info
'
.
trim
());
}
...
...
test/src/extensions/dynamic_extensions_test.dart
View file @
dc9f9d7
import
'package:flutter_test/flutter_test.dart'
;
import
'package:get/utils.dart'
;
void
main
(
)
{
test
(
''
,
()
{});
group
(
'Log Extension'
,
()
{
test
(
'String test'
,
()
{
var
value
=
'string'
;
var
expected
=
''
;
void
logFunction
(
String
prefix
,
dynamic
value
,
String
info
)
{
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
)
{
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
)
{
expected
=
'
$prefix
$value
$info
'
.
trim
();
}
value
.
printError
(
logFunction:
logFunction
);
expect
(
expected
,
'Error: double 1.0'
);
});
});
}
...
...
Please
register
or
login
to post a comment