-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdip_example.dart
60 lines (45 loc) · 915 Bytes
/
dip_example.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
55
56
57
58
59
60
//! RIGHT Way
/// Low Level
abstract class BaseMail {
send();
}
class HotMail implements BaseMail {
@override
send() {}
}
class Gmail implements BaseMail {
@override
send() {}
}
/// high level
class Notification {
BaseMail baseMail;
Notification(this.baseMail);
void send() => baseMail.send();
}
/// in Main
void main(List<String> args) {
Notification notification = Notification(Gmail());
notification.send();
}
//! WRONG Way
//// /// Low Level
// class HotMail {
// send() {}
// }
// class Gmail {
// send() {}
// }
// /// high level
// class Notification {
// HotMail hotMail = HotMail();
// Gmail gmail = Gmail();
// void sendGmail() => gmail.send();
// void sendHotMail() => hotMail.send();
// }
// /// in Main
// void main(List<String> args) {
// Notification notification = Notification();
// notification.sendGmail();
// notification.sendHotMail();
// }