patterns/adapter.dart

30 lines
485 B
Dart
Raw Normal View History

2022-03-01 10:30:23 +03:00
const adapteeMessage = 'Adaptee#method was called';
class Adaptee {
String method() {
print('Adaptee#method is being called');
return adapteeMessage;
}
}
abstract class Target {
String call();
}
class Adapter implements Target {
String call() {
var adaptee = Adaptee();
print('Adapter#call is being called');
return adaptee.method();
}
}
void main() {
var adapter = Adapter();
var result = adapter.call();
assert(result == adapteeMessage);
}