forked from vandadnp/flutter-tips-and-tricks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsymbol-in-dart.dart
54 lines (47 loc) · 1.25 KB
/
symbol-in-dart.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// 🐦 Twitter https://twitter.com/vandadnp
// 🔵 LinkedIn https://linkedin.com/in/vandadnp
// 🎥 YouTube https://youtube.com/c/vandadnp
// 💙 Free Flutter Course https://linktr.ee/vandadnp
// 📦 11+ Hours Bloc Course https://youtu.be/Mn254cnduOY
// 🔶 7+ Hours MobX Course https://youtu.be/7Od55PBxYkI
// 🤝 Want to support my work? https://buymeacoffee.com/vandad
import 'dart:developer' as devtools show log;
import 'package:flutter/foundation.dart' show immutable;
@immutable
class Person {
final String fullName;
final int age;
const Person({
required this.fullName,
required this.age,
});
@override
String toString() => {
'fullName': fullName,
'age': age,
}.toString();
}
Person constructPerson({
required String firstName,
required String lastName,
required int age,
}) =>
Person(
fullName: '$firstName $lastName',
age: age,
);
extension Log on Object {
void log() => devtools.log(toString());
}
void testIt() {
final person = Function.apply(
constructPerson,
[],
{
#firstName: 'Foo',
#lastName: 'Bar',
#age: 20,
},
) as Person;
person.log(); // {fullName: Foo Bar, age: 20}
}