2022-03-18 15:03:50 +03:00
|
|
|
const adapteeMessage = 'Вызов адаптирующегося метода';
|
2022-03-01 10:30:23 +03:00
|
|
|
|
|
|
|
class Adaptee {
|
|
|
|
String method() {
|
2022-03-18 15:03:50 +03:00
|
|
|
print('Вызов адаптирующегося метода');
|
2022-03-01 10:30:23 +03:00
|
|
|
|
|
|
|
return adapteeMessage;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
abstract class Target {
|
|
|
|
String call();
|
|
|
|
}
|
|
|
|
|
|
|
|
class Adapter implements Target {
|
|
|
|
String call() {
|
|
|
|
var adaptee = Adaptee();
|
2022-03-18 15:03:50 +03:00
|
|
|
print('Вызов адаптирующегося метода');
|
2022-03-01 10:30:23 +03:00
|
|
|
|
|
|
|
return adaptee.method();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void main() {
|
|
|
|
var adapter = Adapter();
|
|
|
|
var result = adapter.call();
|
|
|
|
|
2022-03-18 15:03:50 +03:00
|
|
|
print(result == adapteeMessage);
|
2022-03-01 10:30:23 +03:00
|
|
|
}
|