File tree Expand file tree Collapse file tree 1 file changed +45
-0
lines changed
patterns/abstract_factory/conceptual_gui_factory Expand file tree Collapse file tree 1 file changed +45
-0
lines changed Original file line number Diff line number Diff line change 1+ # Memento pattern
2+ Memento is a behavioral design pattern that lets you save and restore the previous state of an
3+ object without revealing the details of its implementation.
4+
5+ Tutorial: [ here] ( https://refactoring.guru/design-patterns/memento ) .
6+
7+ ### Online demo:
8+ Click on the picture to see the [ demo] ( https://RefactoringGuru.github.io/design-patterns-dart/#/memento/flutter_memento_editor ) .
9+
10+ [ ![ image] ( https://user-images.githubusercontent.com/8049534/165401175-88bc4593-4624-45b4-8c03-6f1390ed771a.png )] ( https://refactoringguru.github.io/design-patterns-dart/#/memento/flutter_memento_editor )
11+
12+ ### Dependency Patterns
13+ This complex example includes these implementations:
14+ - [[ AppObserver] ( https://github.com/RefactoringGuru/design-patterns-dart/tree/main/patterns/observer/app_observer )]
15+ - [[ SubscriberWidget] ( https://github.com/RefactoringGuru/design-patterns-dart/tree/main/patterns/observer/subscriber_flutter_widget )]
16+
17+ ### Diagram:
18+ ![ image] ( https://user-images.githubusercontent.com/8049534/165758516-1de543f5-666d-4e07-958d-2d8fceb73af9.png )
19+
20+ ### Client code:
21+ ``` dart
22+ void main() {
23+ final guiFactory = GUIFactory();
24+ final app = Application(guiFactory);
25+ app.paint();
26+ }
27+
28+ abstract class GUIFactory {
29+ factory GUIFactory() {
30+ if (Platform.isMacOS) {
31+ return MacOSFactory();
32+ } else {
33+ return WindowsFactory();
34+ }
35+ }
36+
37+ /*...*/
38+ }
39+ ```
40+
41+ ### Output:
42+ ```
43+ You have created WindowsButton.
44+ You have created WindowsCheckbox.
45+ ```
You can’t perform that action at this time.
0 commit comments