Skip to content

Commit aaa5f39

Browse files
authored
Create colorful-logs-in-flutter.dart
1 parent 7263053 commit aaa5f39

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// 🐦 Twitter https://twitter.com/vandadnp
2+
// 🔵 LinkedIn https://linkedin.com/in/vandadnp
3+
// 🎥 YouTube https://youtube.com/c/vandadnp
4+
// 💙 Free Flutter Course https://linktr.ee/vandadnp
5+
// 📦 11+ Hours Bloc Course https://youtu.be/Mn254cnduOY
6+
// 🔶 7+ Hours MobX Course https://youtu.be/7Od55PBxYkI
7+
// 🦄 8+ Hours RxSwift Coursde https://youtu.be/xBFWMYmm9ro
8+
// 🤝 Want to support my work? https://buymeacoffee.com/vandad
9+
10+
import 'dart:developer' as devtools show log;
11+
12+
extension Log on Object? {
13+
void log() =>
14+
devtools.log(this?.toString() ?? '\x1b[101m\x1b[30mNULL\x1b[0m');
15+
}
16+
17+
void testIt([
18+
String? firstName,
19+
String lastName = 'Doe',
20+
String? address = 'NULL',
21+
int? age,
22+
List<Object> list1 = const [],
23+
List<Object>? list2,
24+
]) {
25+
firstName.log(); // NULL (in colors)
26+
lastName.log(); // DOE
27+
address.log(); // NULL
28+
age.log(); // NULL (in colors)
29+
list1.log(); // []
30+
list2.log(); // NULL (in colors)
31+
}

0 commit comments

Comments
 (0)