File tree Expand file tree Collapse file tree 6 files changed +71
-1
lines changed Expand file tree Collapse file tree 6 files changed +71
-1
lines changed Original file line number Diff line number Diff line change 15158 . 组合模式
16169 . 装饰者模式
171710 . 外观/门面模式
18- 11 . 享元模式
18+ 11 . 享元模式
19+ 12 . 代理模式
20+
21+ ### 行为型模式
22+ 待添加
Original file line number Diff line number Diff line change @@ -37,4 +37,7 @@ class StringConst {
3737
3838 //享元模式
3939 static const String FLYWEIGHT_ = "享元模式" ;
40+
41+ //享元模式
42+ static const String PROXY_ = "代理模式" ;
4043}
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ import 'package:flutter_design/page/decorator/decorator_page.dart';
77import 'package:flutter_design/page/facade/facade_page.dart' ;
88import 'package:flutter_design/page/filter/filter_page.dart' ;
99import 'package:flutter_design/page/flyweight/flyweight_page.dart' ;
10+ import 'package:flutter_design/page/proxy/proxy_page.dart' ;
1011
1112import 'constant/page_const.dart' ;
1213import 'constant/string_const.dart' ;
@@ -37,6 +38,7 @@ class MyApp extends StatelessWidget {
3738 PageConst .DECORATOR_PAGE : (context) => DecoratorPage (),
3839 PageConst .FACADE_PAGE : (context) => FacadePage (),
3940 PageConst .FLYWEIGHT_PAGE : (context) => FlyweightPage (),
41+ PageConst .PROXY_PAGE : (context) => ProxyPage (),
4042 },
4143 );
4244 }
Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ Map<String, String> map = {
2626 PageConst .DECORATOR_PAGE : StringConst .DECORATOR_ ,
2727 PageConst .FACADE_PAGE : StringConst .FACADE_ ,
2828 PageConst .FLYWEIGHT_PAGE : StringConst .FLYWEIGHT_ ,
29+ PageConst .PROXY_PAGE : StringConst .PROXY_ ,
2930};
3031
3132class _HomePageState extends State <HomePage > {
Original file line number Diff line number Diff line change 1+ /// Created by NieBin on 2020-03-27
2+ /// Github: https://github.com/nb312
3+ /// Email: niebin312@gmail.com
4+ abstract class BuyProduct {
5+ void buyPhone ();
6+ }
7+
8+ class BuyHuWei implements BuyProduct {
9+ @override
10+ void buyPhone () {
11+ print ("购买华为手机" );
12+ }
13+ }
14+
15+ class ProxyBuy implements BuyProduct {
16+ @override
17+ void buyPhone () {
18+ BuyProduct hua = BuyHuWei ();
19+ hua.buyPhone ();
20+ print ("我爱中国?" );
21+ }
22+ }
Original file line number Diff line number Diff line change 1+ import 'package:flutter/material.dart' ;
2+ import 'package:flutter_design/constant/string_const.dart' ;
3+ import 'package:flutter_design/page/proxy/proxy_mode.dart' ;
4+
5+ /// Created by NieBin on 2020-03-27
6+ /// Github: https://github.com/nb312
7+ /// Email: niebin312@gmail.com
8+
9+ class ProxyPage extends StatefulWidget {
10+ @override
11+ _ProxyPageState createState () => _ProxyPageState ();
12+ }
13+
14+ class _ProxyPageState extends State <ProxyPage > {
15+ @override
16+ Widget build (BuildContext context) {
17+ return Scaffold (
18+ appBar: AppBar (
19+ title: Text (StringConst .PROXY_ ),
20+ ),
21+ body: Container (
22+ child: Center (
23+ child: FlatButton (
24+ color: Colors .brown,
25+ child: Padding (
26+ padding: const EdgeInsets .symmetric (horizontal: 20 , vertical: 10 ),
27+ child: Text ("购买手机" ),
28+ ),
29+ onPressed: () {
30+ BuyProduct product = ProxyBuy ();
31+ product.buyPhone ();
32+ },
33+ ),
34+ ),
35+ ),
36+ );
37+ }
38+ }
You can’t perform that action at this time.
0 commit comments