We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents d7b8b72 + 5682281 commit f99a156Copy full SHA for f99a156
README.md
@@ -15,4 +15,8 @@
15
8. 组合模式
16
9. 装饰者模式
17
10. 外观/门面模式
18
-11. 享元模式
+11. 享元模式
19
+12. 代理模式
20
+
21
+### 行为型模式
22
+待添加
lib/constant/string_const.dart
@@ -37,4 +37,7 @@ class StringConst {
37
38
//享元模式
39
static const String FLYWEIGHT_ = "享元模式";
40
41
+ //享元模式
42
+ static const String PROXY_ = "代理模式";
43
}
lib/main.dart
@@ -7,6 +7,7 @@ import 'package:flutter_design/page/decorator/decorator_page.dart';
7
import 'package:flutter_design/page/facade/facade_page.dart';
8
import 'package:flutter_design/page/filter/filter_page.dart';
9
import 'package:flutter_design/page/flyweight/flyweight_page.dart';
10
+import 'package:flutter_design/page/proxy/proxy_page.dart';
11
12
import 'constant/page_const.dart';
13
import 'constant/string_const.dart';
@@ -37,6 +38,7 @@ class MyApp extends StatelessWidget {
PageConst.DECORATOR_PAGE: (context) => DecoratorPage(),
PageConst.FACADE_PAGE: (context) => FacadePage(),
PageConst.FLYWEIGHT_PAGE: (context) => FlyweightPage(),
+ PageConst.PROXY_PAGE: (context) => ProxyPage(),
},
);
44
lib/page/home_page.dart
@@ -26,6 +26,7 @@ Map<String, String> map = {
26
PageConst.DECORATOR_PAGE: StringConst.DECORATOR_,
27
PageConst.FACADE_PAGE: StringConst.FACADE_,
28
PageConst.FLYWEIGHT_PAGE: StringConst.FLYWEIGHT_,
29
+ PageConst.PROXY_PAGE: StringConst.PROXY_,
30
};
31
32
class _HomePageState extends State<HomePage> {
lib/page/proxy/proxy_mode.dart
@@ -0,0 +1,22 @@
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
+}
+class BuyHuWei implements BuyProduct {
+ @override
+ void buyPhone() {
+ print("购买华为手机");
+ }
14
+class ProxyBuy implements BuyProduct {
+ BuyProduct hua = BuyHuWei();
+ hua.buyPhone();
+ print("我爱中国?");
lib/page/proxy/proxy_page.dart
@@ -0,0 +1,38 @@
+import 'package:flutter/material.dart';
+import 'package:flutter_design/constant/string_const.dart';
+import 'package:flutter_design/page/proxy/proxy_mode.dart';
+class ProxyPage extends StatefulWidget {
+ _ProxyPageState createState() => _ProxyPageState();
+class _ProxyPageState extends State<ProxyPage> {
+ Widget build(BuildContext context) {
+ return Scaffold(
+ appBar: AppBar(
+ title: Text(StringConst.PROXY_),
+ ),
+ body: Container(
+ child: Center(
23
+ child: FlatButton(
24
+ color: Colors.brown,
25
+ child: Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 10),
+ child: Text("购买手机"),
+ onPressed: () {
+ BuyProduct product = ProxyBuy();
+ product.buyPhone();
+ },
33
34
35
36
+ );
AltStyle によって変換されたページ (->オリジナル) / アドレス: モード: デフォルト 音声ブラウザ ルビ付き 配色反転 文字拡大 モバイル
0 commit comments