├── .gitignore
├── .metadata
├── README.md
├── android
├── .gitignore
├── app
│ ├── build.gradle
│ └── src
│ │ ├── debug
│ │ └── AndroidManifest.xml
│ │ ├── main
│ │ ├── AndroidManifest.xml
│ │ ├── kotlin
│ │ │ └── com
│ │ │ │ └── nb
│ │ │ │ └── flutter_design
│ │ │ │ └── MainActivity.kt
│ │ └── res
│ │ │ ├── drawable
│ │ │ └── launch_background.xml
│ │ │ ├── mipmap-hdpi
│ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-mdpi
│ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xhdpi
│ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xxhdpi
│ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xxxhdpi
│ │ │ └── ic_launcher.png
│ │ │ └── values
│ │ │ └── styles.xml
│ │ └── profile
│ │ └── AndroidManifest.xml
├── build.gradle
├── gradle.properties
├── gradle
│ └── wrapper
│ │ └── gradle-wrapper.properties
└── settings.gradle
├── ios
├── .gitignore
├── Flutter
│ ├── AppFrameworkInfo.plist
│ ├── Debug.xcconfig
│ └── Release.xcconfig
├── Runner.xcodeproj
│ ├── project.pbxproj
│ ├── project.xcworkspace
│ │ └── contents.xcworkspacedata
│ └── xcshareddata
│ │ └── xcschemes
│ │ └── Runner.xcscheme
├── Runner.xcworkspace
│ └── contents.xcworkspacedata
└── Runner
│ ├── AppDelegate.swift
│ ├── Assets.xcassets
│ ├── AppIcon.appiconset
│ │ ├── Contents.json
│ │ ├── Icon-App-1024x1024@1x.png
│ │ ├── Icon-App-20x20@1x.png
│ │ ├── Icon-App-20x20@2x.png
│ │ ├── Icon-App-20x20@3x.png
│ │ ├── Icon-App-29x29@1x.png
│ │ ├── Icon-App-29x29@2x.png
│ │ ├── Icon-App-29x29@3x.png
│ │ ├── Icon-App-40x40@1x.png
│ │ ├── Icon-App-40x40@2x.png
│ │ ├── Icon-App-40x40@3x.png
│ │ ├── Icon-App-60x60@2x.png
│ │ ├── Icon-App-60x60@3x.png
│ │ ├── Icon-App-76x76@1x.png
│ │ ├── Icon-App-76x76@2x.png
│ │ └── Icon-App-83.5x83.5@2x.png
│ └── LaunchImage.imageset
│ │ ├── Contents.json
│ │ ├── LaunchImage.png
│ │ ├── LaunchImage@2x.png
│ │ ├── LaunchImage@3x.png
│ │ └── README.md
│ ├── Base.lproj
│ ├── LaunchScreen.storyboard
│ └── Main.storyboard
│ ├── Info.plist
│ └── Runner-Bridging-Header.h
├── lib
├── constant
│ ├── color_const.dart
│ ├── page_const.dart
│ └── string_const.dart
├── main.dart
└── page
│ ├── _page.dart
│ ├── adapter
│ ├── adapter_page.dart
│ ├── adapter_target.dart
│ └── gun.dart
│ ├── bridge
│ ├── bridge_mode.dart
│ └── bridge_page.dart
│ ├── builder
│ ├── book.dart
│ ├── builder.dart
│ ├── builder_page.dart
│ └── director.dart
│ ├── combination
│ ├── combination_mode.dart
│ └── combination_page.dart
│ ├── command
│ ├── command_mode.dart
│ └── command_page.dart
│ ├── decorator
│ ├── decorator_mode.dart
│ └── decorator_page.dart
│ ├── duty
│ ├── duty_mode.dart
│ └── duty_page.dart
│ ├── facade
│ ├── facade_model.dart
│ └── facade_page.dart
│ ├── factory
│ ├── color_concrete.dart
│ ├── describe_text.dart
│ ├── factory_abstract.dart
│ ├── factory_concrete.dart
│ ├── factory_page.dart
│ └── shape_concrete.dart
│ ├── filter
│ ├── filter_mode.dart
│ └── filter_page.dart
│ ├── flyweight
│ ├── flyweight_mode.dart
│ └── flyweight_page.dart
│ ├── home_page.dart
│ ├── interpreter
│ ├── intepreter_page.dart
│ └── interpreter_mode.dart
│ ├── iterator
│ ├── Iterator_page.dart
│ └── iterator_mode.dart
│ ├── memory
│ ├── memory_mode.dart
│ └── memory_page.dart
│ ├── midd
│ ├── mid_mode.dart
│ └── mid_page.dart
│ ├── observer
│ ├── observer_mode.dart
│ └── observer_page.dart
│ ├── prototype
│ ├── prototype_page.dart
│ └── prototype_product.dart
│ ├── proxy
│ ├── proxy_mode.dart
│ └── proxy_page.dart
│ ├── single
│ ├── single_manager.dart
│ └── single_page.dart
│ ├── state
│ ├── state_mode.dart
│ └── state_page.dart
│ ├── strategy
│ ├── strategy_mode.dart
│ └── strategy_page.dart
│ └── template
│ ├── template_mode.dart
│ └── template_page.dart
├── pubspec.lock
├── pubspec.yaml
├── test
└── widget_test.dart
└── web
├── icons
├── Icon-192.png
└── Icon-512.png
├── index.html
└── manifest.json
/.gitignore:
--------------------------------------------------------------------------------
1 | # Miscellaneous
2 | *.class
3 | *.log
4 | *.pyc
5 | *.swp
6 | .DS_Store
7 | .atom/
8 | .buildlog/
9 | .history
10 | .svn/
11 |
12 | # IntelliJ related
13 | *.iml
14 | *.ipr
15 | *.iws
16 | .idea/
17 |
18 | # The .vscode folder contains launch configuration and tasks you configure in
19 | # VS Code which you may wish to be included in version control, so this line
20 | # is commented out by default.
21 | #.vscode/
22 |
23 | # Flutter/Dart/Pub related
24 | **/doc/api/
25 | .dart_tool/
26 | .flutter-plugins
27 | .flutter-plugins-dependencies
28 | .packages
29 | .pub-cache/
30 | .pub/
31 | /build/
32 |
33 | # Web related
34 | lib/generated_plugin_registrant.dart
35 |
36 | # Exceptions to above rules.
37 | !/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages
38 |
--------------------------------------------------------------------------------
/.metadata:
--------------------------------------------------------------------------------
1 | # This file tracks properties of this Flutter project.
2 | # Used by Flutter tool to assess capabilities and perform upgrades etc.
3 | #
4 | # This file should be version controlled and should not be manually edited.
5 |
6 | version:
7 | revision: fabeb2a16f1d008ab8230f450c49141d35669798
8 | channel: beta
9 |
10 | project_type: app
11 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Flutter 设计模式
2 | 主要是利用Flutter来实现各种设计模式,对设计模式的加深理解
3 |
4 | # 已实现
5 | ### 创造型模式
6 | 1. 工厂/抽象工厂模式
7 | 2. 单例模式
8 | 3. 建造者模式
9 | 4. 原型模式
10 |
11 | ### 结构型模式
12 | 5. 适配器模式
13 | 6. 桥接模式
14 | 7. 过滤器/标准模式
15 | 8. 组合模式
16 | 9. 装饰者模式
17 | 10. 外观/门面模式
18 | 11. 享元模式
19 | 12. 代理模式
20 |
21 | ### 行为型模式
22 | 13. 责任链模式
23 | 14. 命令模式
24 | 15. 解释器模式
25 | 16. 迭代器模式
26 | 17. 中介者模式
27 | 18. 备忘录模式
28 | 19. 观察者模式
29 | 20. 状态模式
30 | 21. 策略模式
31 | 22. 模版模式
--------------------------------------------------------------------------------
/android/.gitignore:
--------------------------------------------------------------------------------
1 | gradle-wrapper.jar
2 | /.gradle
3 | /captures/
4 | /gradlew
5 | /gradlew.bat
6 | /local.properties
7 | GeneratedPluginRegistrant.java
8 |
--------------------------------------------------------------------------------
/android/app/build.gradle:
--------------------------------------------------------------------------------
1 | def localProperties = new Properties()
2 | def localPropertiesFile = rootProject.file('local.properties')
3 | if (localPropertiesFile.exists()) {
4 | localPropertiesFile.withReader('UTF-8') { reader ->
5 | localProperties.load(reader)
6 | }
7 | }
8 |
9 | def flutterRoot = localProperties.getProperty('flutter.sdk')
10 | if (flutterRoot == null) {
11 | throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
12 | }
13 |
14 | def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
15 | if (flutterVersionCode == null) {
16 | flutterVersionCode = '1'
17 | }
18 |
19 | def flutterVersionName = localProperties.getProperty('flutter.versionName')
20 | if (flutterVersionName == null) {
21 | flutterVersionName = '1.0'
22 | }
23 |
24 | apply plugin: 'com.android.application'
25 | apply plugin: 'kotlin-android'
26 | apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
27 |
28 | android {
29 | compileSdkVersion 28
30 |
31 | sourceSets {
32 | main.java.srcDirs += 'src/main/kotlin'
33 | }
34 |
35 | lintOptions {
36 | disable 'InvalidPackage'
37 | }
38 |
39 | defaultConfig {
40 | // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
41 | applicationId "com.nb.flutter_design"
42 | minSdkVersion 16
43 | targetSdkVersion 28
44 | versionCode flutterVersionCode.toInteger()
45 | versionName flutterVersionName
46 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
47 | }
48 |
49 | buildTypes {
50 | release {
51 | // TODO: Add your own signing config for the release build.
52 | // Signing with the debug keys for now, so `flutter run --release` works.
53 | signingConfig signingConfigs.debug
54 | }
55 | }
56 | }
57 |
58 | flutter {
59 | source '../..'
60 | }
61 |
62 | dependencies {
63 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
64 | testImplementation 'junit:junit:4.12'
65 | androidTestImplementation 'androidx.test:runner:1.1.1'
66 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
67 | }
68 |
--------------------------------------------------------------------------------
/android/app/src/debug/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/android/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
8 |
12 |
19 |
23 |
27 |
32 |
36 |
37 |
38 |
39 |
40 |
41 |
43 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/android/app/src/main/kotlin/com/nb/flutter_design/MainActivity.kt:
--------------------------------------------------------------------------------
1 | package com.nb.flutter_design
2 |
3 | import androidx.annotation.NonNull;
4 | import io.flutter.embedding.android.FlutterActivity
5 | import io.flutter.embedding.engine.FlutterEngine
6 | import io.flutter.plugins.GeneratedPluginRegistrant
7 |
8 | class MainActivity: FlutterActivity() {
9 | override fun configureFlutterEngine(@NonNull flutterEngine: FlutterEngine) {
10 | GeneratedPluginRegistrant.registerWith(flutterEngine);
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/android/app/src/main/res/drawable/launch_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
12 |
13 |
--------------------------------------------------------------------------------
/android/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FlutterOpen/design_patterns/93b7059718ac42d9d772205eaf697f81fb8aef07/android/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/android/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FlutterOpen/design_patterns/93b7059718ac42d9d772205eaf697f81fb8aef07/android/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FlutterOpen/design_patterns/93b7059718ac42d9d772205eaf697f81fb8aef07/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FlutterOpen/design_patterns/93b7059718ac42d9d772205eaf697f81fb8aef07/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FlutterOpen/design_patterns/93b7059718ac42d9d772205eaf697f81fb8aef07/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/android/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
9 |
15 |
18 |
19 |
--------------------------------------------------------------------------------
/android/app/src/profile/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/android/build.gradle:
--------------------------------------------------------------------------------
1 | buildscript {
2 | ext.kotlin_version = '1.3.50'
3 | repositories {
4 | google()
5 | jcenter()
6 | }
7 |
8 | dependencies {
9 | classpath 'com.android.tools.build:gradle:3.5.0'
10 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
11 | }
12 | }
13 |
14 | allprojects {
15 | repositories {
16 | google()
17 | jcenter()
18 | }
19 | }
20 |
21 | rootProject.buildDir = '../build'
22 | subprojects {
23 | project.buildDir = "${rootProject.buildDir}/${project.name}"
24 | }
25 | subprojects {
26 | project.evaluationDependsOn(':app')
27 | }
28 |
29 | task clean(type: Delete) {
30 | delete rootProject.buildDir
31 | }
32 |
--------------------------------------------------------------------------------
/android/gradle.properties:
--------------------------------------------------------------------------------
1 | org.gradle.jvmargs=-Xmx1536M
2 | android.enableR8=true
3 | android.useAndroidX=true
4 | android.enableJetifier=true
5 |
--------------------------------------------------------------------------------
/android/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Fri Jun 23 08:50:38 CEST 2017
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip
7 |
--------------------------------------------------------------------------------
/android/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
3 | def flutterProjectRoot = rootProject.projectDir.parentFile.toPath()
4 |
5 | def plugins = new Properties()
6 | def pluginsFile = new File(flutterProjectRoot.toFile(), '.flutter-plugins')
7 | if (pluginsFile.exists()) {
8 | pluginsFile.withReader('UTF-8') { reader -> plugins.load(reader) }
9 | }
10 |
11 | plugins.each { name, path ->
12 | def pluginDirectory = flutterProjectRoot.resolve(path).resolve('android').toFile()
13 | include ":$name"
14 | project(":$name").projectDir = pluginDirectory
15 | }
16 |
--------------------------------------------------------------------------------
/ios/.gitignore:
--------------------------------------------------------------------------------
1 | *.mode1v3
2 | *.mode2v3
3 | *.moved-aside
4 | *.pbxuser
5 | *.perspectivev3
6 | **/*sync/
7 | .sconsign.dblite
8 | .tags*
9 | **/.vagrant/
10 | **/DerivedData/
11 | Icon?
12 | **/Pods/
13 | **/.symlinks/
14 | profile
15 | xcuserdata
16 | **/.generated/
17 | Flutter/App.framework
18 | Flutter/Flutter.framework
19 | Flutter/Flutter.podspec
20 | Flutter/Generated.xcconfig
21 | Flutter/app.flx
22 | Flutter/app.zip
23 | Flutter/flutter_assets/
24 | Flutter/flutter_export_environment.sh
25 | ServiceDefinitions.json
26 | Runner/GeneratedPluginRegistrant.*
27 |
28 | # Exceptions to above rules.
29 | !default.mode1v3
30 | !default.mode2v3
31 | !default.pbxuser
32 | !default.perspectivev3
33 |
--------------------------------------------------------------------------------
/ios/Flutter/AppFrameworkInfo.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | $(DEVELOPMENT_LANGUAGE)
7 | CFBundleExecutable
8 | App
9 | CFBundleIdentifier
10 | io.flutter.flutter.app
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | App
15 | CFBundlePackageType
16 | FMWK
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1.0
23 | MinimumOSVersion
24 | 8.0
25 |
26 |
27 |
--------------------------------------------------------------------------------
/ios/Flutter/Debug.xcconfig:
--------------------------------------------------------------------------------
1 | #include "Generated.xcconfig"
2 |
--------------------------------------------------------------------------------
/ios/Flutter/Release.xcconfig:
--------------------------------------------------------------------------------
1 | #include "Generated.xcconfig"
2 |
--------------------------------------------------------------------------------
/ios/Runner.xcodeproj/project.pbxproj:
--------------------------------------------------------------------------------
1 | // !$*UTF8*$!
2 | {
3 | archiveVersion = 1;
4 | classes = {
5 | };
6 | objectVersion = 46;
7 | objects = {
8 |
9 | /* Begin PBXBuildFile section */
10 | 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; };
11 | 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
12 | 3B80C3941E831B6300D905FE /* App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; };
13 | 3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
14 | 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; };
15 | 9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; };
16 | 9705A1C71CF904A300538489 /* Flutter.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
17 | 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; };
18 | 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; };
19 | 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; };
20 | /* End PBXBuildFile section */
21 |
22 | /* Begin PBXCopyFilesBuildPhase section */
23 | 9705A1C41CF9048500538489 /* Embed Frameworks */ = {
24 | isa = PBXCopyFilesBuildPhase;
25 | buildActionMask = 2147483647;
26 | dstPath = "";
27 | dstSubfolderSpec = 10;
28 | files = (
29 | 3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */,
30 | 9705A1C71CF904A300538489 /* Flutter.framework in Embed Frameworks */,
31 | );
32 | name = "Embed Frameworks";
33 | runOnlyForDeploymentPostprocessing = 0;
34 | };
35 | /* End PBXCopyFilesBuildPhase section */
36 |
37 | /* Begin PBXFileReference section */
38 | 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; };
39 | 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; };
40 | 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; };
41 | 3B80C3931E831B6300D905FE /* App.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = App.framework; path = Flutter/App.framework; sourceTree = ""; };
42 | 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = ""; };
43 | 74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; };
44 | 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; };
45 | 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = ""; };
46 | 9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = ""; };
47 | 9740EEBA1CF902C7004384FC /* Flutter.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Flutter.framework; path = Flutter/Flutter.framework; sourceTree = ""; };
48 | 97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; };
49 | 97C146FB1CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; };
50 | 97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; };
51 | 97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; };
52 | 97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
53 | /* End PBXFileReference section */
54 |
55 | /* Begin PBXFrameworksBuildPhase section */
56 | 97C146EB1CF9000F007C117D /* Frameworks */ = {
57 | isa = PBXFrameworksBuildPhase;
58 | buildActionMask = 2147483647;
59 | files = (
60 | 9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */,
61 | 3B80C3941E831B6300D905FE /* App.framework in Frameworks */,
62 | );
63 | runOnlyForDeploymentPostprocessing = 0;
64 | };
65 | /* End PBXFrameworksBuildPhase section */
66 |
67 | /* Begin PBXGroup section */
68 | 9740EEB11CF90186004384FC /* Flutter */ = {
69 | isa = PBXGroup;
70 | children = (
71 | 3B80C3931E831B6300D905FE /* App.framework */,
72 | 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */,
73 | 9740EEBA1CF902C7004384FC /* Flutter.framework */,
74 | 9740EEB21CF90195004384FC /* Debug.xcconfig */,
75 | 7AFA3C8E1D35360C0083082E /* Release.xcconfig */,
76 | 9740EEB31CF90195004384FC /* Generated.xcconfig */,
77 | );
78 | name = Flutter;
79 | sourceTree = "";
80 | };
81 | 97C146E51CF9000F007C117D = {
82 | isa = PBXGroup;
83 | children = (
84 | 9740EEB11CF90186004384FC /* Flutter */,
85 | 97C146F01CF9000F007C117D /* Runner */,
86 | 97C146EF1CF9000F007C117D /* Products */,
87 | );
88 | sourceTree = "";
89 | };
90 | 97C146EF1CF9000F007C117D /* Products */ = {
91 | isa = PBXGroup;
92 | children = (
93 | 97C146EE1CF9000F007C117D /* Runner.app */,
94 | );
95 | name = Products;
96 | sourceTree = "";
97 | };
98 | 97C146F01CF9000F007C117D /* Runner */ = {
99 | isa = PBXGroup;
100 | children = (
101 | 97C146FA1CF9000F007C117D /* Main.storyboard */,
102 | 97C146FD1CF9000F007C117D /* Assets.xcassets */,
103 | 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */,
104 | 97C147021CF9000F007C117D /* Info.plist */,
105 | 97C146F11CF9000F007C117D /* Supporting Files */,
106 | 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */,
107 | 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */,
108 | 74858FAE1ED2DC5600515810 /* AppDelegate.swift */,
109 | 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */,
110 | );
111 | path = Runner;
112 | sourceTree = "";
113 | };
114 | 97C146F11CF9000F007C117D /* Supporting Files */ = {
115 | isa = PBXGroup;
116 | children = (
117 | );
118 | name = "Supporting Files";
119 | sourceTree = "";
120 | };
121 | /* End PBXGroup section */
122 |
123 | /* Begin PBXNativeTarget section */
124 | 97C146ED1CF9000F007C117D /* Runner */ = {
125 | isa = PBXNativeTarget;
126 | buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */;
127 | buildPhases = (
128 | 9740EEB61CF901F6004384FC /* Run Script */,
129 | 97C146EA1CF9000F007C117D /* Sources */,
130 | 97C146EB1CF9000F007C117D /* Frameworks */,
131 | 97C146EC1CF9000F007C117D /* Resources */,
132 | 9705A1C41CF9048500538489 /* Embed Frameworks */,
133 | 3B06AD1E1E4923F5004D2608 /* Thin Binary */,
134 | );
135 | buildRules = (
136 | );
137 | dependencies = (
138 | );
139 | name = Runner;
140 | productName = Runner;
141 | productReference = 97C146EE1CF9000F007C117D /* Runner.app */;
142 | productType = "com.apple.product-type.application";
143 | };
144 | /* End PBXNativeTarget section */
145 |
146 | /* Begin PBXProject section */
147 | 97C146E61CF9000F007C117D /* Project object */ = {
148 | isa = PBXProject;
149 | attributes = {
150 | LastUpgradeCheck = 1020;
151 | ORGANIZATIONNAME = "";
152 | TargetAttributes = {
153 | 97C146ED1CF9000F007C117D = {
154 | CreatedOnToolsVersion = 7.3.1;
155 | LastSwiftMigration = 1100;
156 | };
157 | };
158 | };
159 | buildConfigurationList = 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */;
160 | compatibilityVersion = "Xcode 3.2";
161 | developmentRegion = en;
162 | hasScannedForEncodings = 0;
163 | knownRegions = (
164 | en,
165 | Base,
166 | );
167 | mainGroup = 97C146E51CF9000F007C117D;
168 | productRefGroup = 97C146EF1CF9000F007C117D /* Products */;
169 | projectDirPath = "";
170 | projectRoot = "";
171 | targets = (
172 | 97C146ED1CF9000F007C117D /* Runner */,
173 | );
174 | };
175 | /* End PBXProject section */
176 |
177 | /* Begin PBXResourcesBuildPhase section */
178 | 97C146EC1CF9000F007C117D /* Resources */ = {
179 | isa = PBXResourcesBuildPhase;
180 | buildActionMask = 2147483647;
181 | files = (
182 | 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */,
183 | 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */,
184 | 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */,
185 | 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */,
186 | );
187 | runOnlyForDeploymentPostprocessing = 0;
188 | };
189 | /* End PBXResourcesBuildPhase section */
190 |
191 | /* Begin PBXShellScriptBuildPhase section */
192 | 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = {
193 | isa = PBXShellScriptBuildPhase;
194 | buildActionMask = 2147483647;
195 | files = (
196 | );
197 | inputPaths = (
198 | );
199 | name = "Thin Binary";
200 | outputPaths = (
201 | );
202 | runOnlyForDeploymentPostprocessing = 0;
203 | shellPath = /bin/sh;
204 | shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" thin";
205 | };
206 | 9740EEB61CF901F6004384FC /* Run Script */ = {
207 | isa = PBXShellScriptBuildPhase;
208 | buildActionMask = 2147483647;
209 | files = (
210 | );
211 | inputPaths = (
212 | );
213 | name = "Run Script";
214 | outputPaths = (
215 | );
216 | runOnlyForDeploymentPostprocessing = 0;
217 | shellPath = /bin/sh;
218 | shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build";
219 | };
220 | /* End PBXShellScriptBuildPhase section */
221 |
222 | /* Begin PBXSourcesBuildPhase section */
223 | 97C146EA1CF9000F007C117D /* Sources */ = {
224 | isa = PBXSourcesBuildPhase;
225 | buildActionMask = 2147483647;
226 | files = (
227 | 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */,
228 | 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */,
229 | );
230 | runOnlyForDeploymentPostprocessing = 0;
231 | };
232 | /* End PBXSourcesBuildPhase section */
233 |
234 | /* Begin PBXVariantGroup section */
235 | 97C146FA1CF9000F007C117D /* Main.storyboard */ = {
236 | isa = PBXVariantGroup;
237 | children = (
238 | 97C146FB1CF9000F007C117D /* Base */,
239 | );
240 | name = Main.storyboard;
241 | sourceTree = "";
242 | };
243 | 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */ = {
244 | isa = PBXVariantGroup;
245 | children = (
246 | 97C147001CF9000F007C117D /* Base */,
247 | );
248 | name = LaunchScreen.storyboard;
249 | sourceTree = "";
250 | };
251 | /* End PBXVariantGroup section */
252 |
253 | /* Begin XCBuildConfiguration section */
254 | 249021D3217E4FDB00AE95B9 /* Profile */ = {
255 | isa = XCBuildConfiguration;
256 | baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */;
257 | buildSettings = {
258 | ALWAYS_SEARCH_USER_PATHS = NO;
259 | CLANG_ANALYZER_NONNULL = YES;
260 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
261 | CLANG_CXX_LIBRARY = "libc++";
262 | CLANG_ENABLE_MODULES = YES;
263 | CLANG_ENABLE_OBJC_ARC = YES;
264 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
265 | CLANG_WARN_BOOL_CONVERSION = YES;
266 | CLANG_WARN_COMMA = YES;
267 | CLANG_WARN_CONSTANT_CONVERSION = YES;
268 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
269 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
270 | CLANG_WARN_EMPTY_BODY = YES;
271 | CLANG_WARN_ENUM_CONVERSION = YES;
272 | CLANG_WARN_INFINITE_RECURSION = YES;
273 | CLANG_WARN_INT_CONVERSION = YES;
274 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
275 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
276 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
277 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
278 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
279 | CLANG_WARN_STRICT_PROTOTYPES = YES;
280 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
281 | CLANG_WARN_UNREACHABLE_CODE = YES;
282 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
283 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
284 | COPY_PHASE_STRIP = NO;
285 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
286 | ENABLE_NS_ASSERTIONS = NO;
287 | ENABLE_STRICT_OBJC_MSGSEND = YES;
288 | GCC_C_LANGUAGE_STANDARD = gnu99;
289 | GCC_NO_COMMON_BLOCKS = YES;
290 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
291 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
292 | GCC_WARN_UNDECLARED_SELECTOR = YES;
293 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
294 | GCC_WARN_UNUSED_FUNCTION = YES;
295 | GCC_WARN_UNUSED_VARIABLE = YES;
296 | IPHONEOS_DEPLOYMENT_TARGET = 8.0;
297 | MTL_ENABLE_DEBUG_INFO = NO;
298 | SDKROOT = iphoneos;
299 | SUPPORTED_PLATFORMS = iphoneos;
300 | TARGETED_DEVICE_FAMILY = "1,2";
301 | VALIDATE_PRODUCT = YES;
302 | };
303 | name = Profile;
304 | };
305 | 249021D4217E4FDB00AE95B9 /* Profile */ = {
306 | isa = XCBuildConfiguration;
307 | baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */;
308 | buildSettings = {
309 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
310 | CLANG_ENABLE_MODULES = YES;
311 | CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
312 | ENABLE_BITCODE = NO;
313 | FRAMEWORK_SEARCH_PATHS = (
314 | "$(inherited)",
315 | "$(PROJECT_DIR)/Flutter",
316 | );
317 | INFOPLIST_FILE = Runner/Info.plist;
318 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
319 | LIBRARY_SEARCH_PATHS = (
320 | "$(inherited)",
321 | "$(PROJECT_DIR)/Flutter",
322 | );
323 | PRODUCT_BUNDLE_IDENTIFIER = com.nb.flutterDesign;
324 | PRODUCT_NAME = "$(TARGET_NAME)";
325 | SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
326 | SWIFT_VERSION = 5.0;
327 | VERSIONING_SYSTEM = "apple-generic";
328 | };
329 | name = Profile;
330 | };
331 | 97C147031CF9000F007C117D /* Debug */ = {
332 | isa = XCBuildConfiguration;
333 | baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */;
334 | buildSettings = {
335 | ALWAYS_SEARCH_USER_PATHS = NO;
336 | CLANG_ANALYZER_NONNULL = YES;
337 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
338 | CLANG_CXX_LIBRARY = "libc++";
339 | CLANG_ENABLE_MODULES = YES;
340 | CLANG_ENABLE_OBJC_ARC = YES;
341 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
342 | CLANG_WARN_BOOL_CONVERSION = YES;
343 | CLANG_WARN_COMMA = YES;
344 | CLANG_WARN_CONSTANT_CONVERSION = YES;
345 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
346 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
347 | CLANG_WARN_EMPTY_BODY = YES;
348 | CLANG_WARN_ENUM_CONVERSION = YES;
349 | CLANG_WARN_INFINITE_RECURSION = YES;
350 | CLANG_WARN_INT_CONVERSION = YES;
351 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
352 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
353 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
354 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
355 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
356 | CLANG_WARN_STRICT_PROTOTYPES = YES;
357 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
358 | CLANG_WARN_UNREACHABLE_CODE = YES;
359 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
360 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
361 | COPY_PHASE_STRIP = NO;
362 | DEBUG_INFORMATION_FORMAT = dwarf;
363 | ENABLE_STRICT_OBJC_MSGSEND = YES;
364 | ENABLE_TESTABILITY = YES;
365 | GCC_C_LANGUAGE_STANDARD = gnu99;
366 | GCC_DYNAMIC_NO_PIC = NO;
367 | GCC_NO_COMMON_BLOCKS = YES;
368 | GCC_OPTIMIZATION_LEVEL = 0;
369 | GCC_PREPROCESSOR_DEFINITIONS = (
370 | "DEBUG=1",
371 | "$(inherited)",
372 | );
373 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
374 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
375 | GCC_WARN_UNDECLARED_SELECTOR = YES;
376 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
377 | GCC_WARN_UNUSED_FUNCTION = YES;
378 | GCC_WARN_UNUSED_VARIABLE = YES;
379 | IPHONEOS_DEPLOYMENT_TARGET = 8.0;
380 | MTL_ENABLE_DEBUG_INFO = YES;
381 | ONLY_ACTIVE_ARCH = YES;
382 | SDKROOT = iphoneos;
383 | TARGETED_DEVICE_FAMILY = "1,2";
384 | };
385 | name = Debug;
386 | };
387 | 97C147041CF9000F007C117D /* Release */ = {
388 | isa = XCBuildConfiguration;
389 | baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */;
390 | buildSettings = {
391 | ALWAYS_SEARCH_USER_PATHS = NO;
392 | CLANG_ANALYZER_NONNULL = YES;
393 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
394 | CLANG_CXX_LIBRARY = "libc++";
395 | CLANG_ENABLE_MODULES = YES;
396 | CLANG_ENABLE_OBJC_ARC = YES;
397 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
398 | CLANG_WARN_BOOL_CONVERSION = YES;
399 | CLANG_WARN_COMMA = YES;
400 | CLANG_WARN_CONSTANT_CONVERSION = YES;
401 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
402 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
403 | CLANG_WARN_EMPTY_BODY = YES;
404 | CLANG_WARN_ENUM_CONVERSION = YES;
405 | CLANG_WARN_INFINITE_RECURSION = YES;
406 | CLANG_WARN_INT_CONVERSION = YES;
407 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
408 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
409 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
410 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
411 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
412 | CLANG_WARN_STRICT_PROTOTYPES = YES;
413 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
414 | CLANG_WARN_UNREACHABLE_CODE = YES;
415 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
416 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
417 | COPY_PHASE_STRIP = NO;
418 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
419 | ENABLE_NS_ASSERTIONS = NO;
420 | ENABLE_STRICT_OBJC_MSGSEND = YES;
421 | GCC_C_LANGUAGE_STANDARD = gnu99;
422 | GCC_NO_COMMON_BLOCKS = YES;
423 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
424 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
425 | GCC_WARN_UNDECLARED_SELECTOR = YES;
426 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
427 | GCC_WARN_UNUSED_FUNCTION = YES;
428 | GCC_WARN_UNUSED_VARIABLE = YES;
429 | IPHONEOS_DEPLOYMENT_TARGET = 8.0;
430 | MTL_ENABLE_DEBUG_INFO = NO;
431 | SDKROOT = iphoneos;
432 | SUPPORTED_PLATFORMS = iphoneos;
433 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
434 | TARGETED_DEVICE_FAMILY = "1,2";
435 | VALIDATE_PRODUCT = YES;
436 | };
437 | name = Release;
438 | };
439 | 97C147061CF9000F007C117D /* Debug */ = {
440 | isa = XCBuildConfiguration;
441 | baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */;
442 | buildSettings = {
443 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
444 | CLANG_ENABLE_MODULES = YES;
445 | CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
446 | ENABLE_BITCODE = NO;
447 | FRAMEWORK_SEARCH_PATHS = (
448 | "$(inherited)",
449 | "$(PROJECT_DIR)/Flutter",
450 | );
451 | INFOPLIST_FILE = Runner/Info.plist;
452 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
453 | LIBRARY_SEARCH_PATHS = (
454 | "$(inherited)",
455 | "$(PROJECT_DIR)/Flutter",
456 | );
457 | PRODUCT_BUNDLE_IDENTIFIER = com.nb.flutterDesign;
458 | PRODUCT_NAME = "$(TARGET_NAME)";
459 | SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
460 | SWIFT_OPTIMIZATION_LEVEL = "-Onone";
461 | SWIFT_VERSION = 5.0;
462 | VERSIONING_SYSTEM = "apple-generic";
463 | };
464 | name = Debug;
465 | };
466 | 97C147071CF9000F007C117D /* Release */ = {
467 | isa = XCBuildConfiguration;
468 | baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */;
469 | buildSettings = {
470 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
471 | CLANG_ENABLE_MODULES = YES;
472 | CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
473 | ENABLE_BITCODE = NO;
474 | FRAMEWORK_SEARCH_PATHS = (
475 | "$(inherited)",
476 | "$(PROJECT_DIR)/Flutter",
477 | );
478 | INFOPLIST_FILE = Runner/Info.plist;
479 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
480 | LIBRARY_SEARCH_PATHS = (
481 | "$(inherited)",
482 | "$(PROJECT_DIR)/Flutter",
483 | );
484 | PRODUCT_BUNDLE_IDENTIFIER = com.nb.flutterDesign;
485 | PRODUCT_NAME = "$(TARGET_NAME)";
486 | SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
487 | SWIFT_VERSION = 5.0;
488 | VERSIONING_SYSTEM = "apple-generic";
489 | };
490 | name = Release;
491 | };
492 | /* End XCBuildConfiguration section */
493 |
494 | /* Begin XCConfigurationList section */
495 | 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */ = {
496 | isa = XCConfigurationList;
497 | buildConfigurations = (
498 | 97C147031CF9000F007C117D /* Debug */,
499 | 97C147041CF9000F007C117D /* Release */,
500 | 249021D3217E4FDB00AE95B9 /* Profile */,
501 | );
502 | defaultConfigurationIsVisible = 0;
503 | defaultConfigurationName = Release;
504 | };
505 | 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */ = {
506 | isa = XCConfigurationList;
507 | buildConfigurations = (
508 | 97C147061CF9000F007C117D /* Debug */,
509 | 97C147071CF9000F007C117D /* Release */,
510 | 249021D4217E4FDB00AE95B9 /* Profile */,
511 | );
512 | defaultConfigurationIsVisible = 0;
513 | defaultConfigurationName = Release;
514 | };
515 | /* End XCConfigurationList section */
516 | };
517 | rootObject = 97C146E61CF9000F007C117D /* Project object */;
518 | }
519 |
--------------------------------------------------------------------------------
/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
32 |
33 |
39 |
40 |
41 |
42 |
43 |
44 |
54 |
56 |
62 |
63 |
64 |
65 |
66 |
67 |
73 |
75 |
81 |
82 |
83 |
84 |
86 |
87 |
90 |
91 |
92 |
--------------------------------------------------------------------------------
/ios/Runner.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/ios/Runner/AppDelegate.swift:
--------------------------------------------------------------------------------
1 | import UIKit
2 | import Flutter
3 |
4 | @UIApplicationMain
5 | @objc class AppDelegate: FlutterAppDelegate {
6 | override func application(
7 | _ application: UIApplication,
8 | didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
9 | ) -> Bool {
10 | GeneratedPluginRegistrant.register(with: self)
11 | return super.application(application, didFinishLaunchingWithOptions: launchOptions)
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "size" : "20x20",
5 | "idiom" : "iphone",
6 | "filename" : "Icon-App-20x20@2x.png",
7 | "scale" : "2x"
8 | },
9 | {
10 | "size" : "20x20",
11 | "idiom" : "iphone",
12 | "filename" : "Icon-App-20x20@3x.png",
13 | "scale" : "3x"
14 | },
15 | {
16 | "size" : "29x29",
17 | "idiom" : "iphone",
18 | "filename" : "Icon-App-29x29@1x.png",
19 | "scale" : "1x"
20 | },
21 | {
22 | "size" : "29x29",
23 | "idiom" : "iphone",
24 | "filename" : "Icon-App-29x29@2x.png",
25 | "scale" : "2x"
26 | },
27 | {
28 | "size" : "29x29",
29 | "idiom" : "iphone",
30 | "filename" : "Icon-App-29x29@3x.png",
31 | "scale" : "3x"
32 | },
33 | {
34 | "size" : "40x40",
35 | "idiom" : "iphone",
36 | "filename" : "Icon-App-40x40@2x.png",
37 | "scale" : "2x"
38 | },
39 | {
40 | "size" : "40x40",
41 | "idiom" : "iphone",
42 | "filename" : "Icon-App-40x40@3x.png",
43 | "scale" : "3x"
44 | },
45 | {
46 | "size" : "60x60",
47 | "idiom" : "iphone",
48 | "filename" : "Icon-App-60x60@2x.png",
49 | "scale" : "2x"
50 | },
51 | {
52 | "size" : "60x60",
53 | "idiom" : "iphone",
54 | "filename" : "Icon-App-60x60@3x.png",
55 | "scale" : "3x"
56 | },
57 | {
58 | "size" : "20x20",
59 | "idiom" : "ipad",
60 | "filename" : "Icon-App-20x20@1x.png",
61 | "scale" : "1x"
62 | },
63 | {
64 | "size" : "20x20",
65 | "idiom" : "ipad",
66 | "filename" : "Icon-App-20x20@2x.png",
67 | "scale" : "2x"
68 | },
69 | {
70 | "size" : "29x29",
71 | "idiom" : "ipad",
72 | "filename" : "Icon-App-29x29@1x.png",
73 | "scale" : "1x"
74 | },
75 | {
76 | "size" : "29x29",
77 | "idiom" : "ipad",
78 | "filename" : "Icon-App-29x29@2x.png",
79 | "scale" : "2x"
80 | },
81 | {
82 | "size" : "40x40",
83 | "idiom" : "ipad",
84 | "filename" : "Icon-App-40x40@1x.png",
85 | "scale" : "1x"
86 | },
87 | {
88 | "size" : "40x40",
89 | "idiom" : "ipad",
90 | "filename" : "Icon-App-40x40@2x.png",
91 | "scale" : "2x"
92 | },
93 | {
94 | "size" : "76x76",
95 | "idiom" : "ipad",
96 | "filename" : "Icon-App-76x76@1x.png",
97 | "scale" : "1x"
98 | },
99 | {
100 | "size" : "76x76",
101 | "idiom" : "ipad",
102 | "filename" : "Icon-App-76x76@2x.png",
103 | "scale" : "2x"
104 | },
105 | {
106 | "size" : "83.5x83.5",
107 | "idiom" : "ipad",
108 | "filename" : "Icon-App-83.5x83.5@2x.png",
109 | "scale" : "2x"
110 | },
111 | {
112 | "size" : "1024x1024",
113 | "idiom" : "ios-marketing",
114 | "filename" : "Icon-App-1024x1024@1x.png",
115 | "scale" : "1x"
116 | }
117 | ],
118 | "info" : {
119 | "version" : 1,
120 | "author" : "xcode"
121 | }
122 | }
123 |
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FlutterOpen/design_patterns/93b7059718ac42d9d772205eaf697f81fb8aef07/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FlutterOpen/design_patterns/93b7059718ac42d9d772205eaf697f81fb8aef07/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FlutterOpen/design_patterns/93b7059718ac42d9d772205eaf697f81fb8aef07/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FlutterOpen/design_patterns/93b7059718ac42d9d772205eaf697f81fb8aef07/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FlutterOpen/design_patterns/93b7059718ac42d9d772205eaf697f81fb8aef07/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FlutterOpen/design_patterns/93b7059718ac42d9d772205eaf697f81fb8aef07/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FlutterOpen/design_patterns/93b7059718ac42d9d772205eaf697f81fb8aef07/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FlutterOpen/design_patterns/93b7059718ac42d9d772205eaf697f81fb8aef07/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FlutterOpen/design_patterns/93b7059718ac42d9d772205eaf697f81fb8aef07/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FlutterOpen/design_patterns/93b7059718ac42d9d772205eaf697f81fb8aef07/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FlutterOpen/design_patterns/93b7059718ac42d9d772205eaf697f81fb8aef07/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FlutterOpen/design_patterns/93b7059718ac42d9d772205eaf697f81fb8aef07/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FlutterOpen/design_patterns/93b7059718ac42d9d772205eaf697f81fb8aef07/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FlutterOpen/design_patterns/93b7059718ac42d9d772205eaf697f81fb8aef07/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FlutterOpen/design_patterns/93b7059718ac42d9d772205eaf697f81fb8aef07/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "LaunchImage.png",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "filename" : "LaunchImage@2x.png",
11 | "scale" : "2x"
12 | },
13 | {
14 | "idiom" : "universal",
15 | "filename" : "LaunchImage@3x.png",
16 | "scale" : "3x"
17 | }
18 | ],
19 | "info" : {
20 | "version" : 1,
21 | "author" : "xcode"
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FlutterOpen/design_patterns/93b7059718ac42d9d772205eaf697f81fb8aef07/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FlutterOpen/design_patterns/93b7059718ac42d9d772205eaf697f81fb8aef07/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FlutterOpen/design_patterns/93b7059718ac42d9d772205eaf697f81fb8aef07/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md:
--------------------------------------------------------------------------------
1 | # Launch Screen Assets
2 |
3 | You can customize the launch screen with your own desired assets by replacing the image files in this directory.
4 |
5 | You can also do it by opening your Flutter project's Xcode project with `open ios/Runner.xcworkspace`, selecting `Runner/Assets.xcassets` in the Project Navigator and dropping in the desired images.
--------------------------------------------------------------------------------
/ios/Runner/Base.lproj/LaunchScreen.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/ios/Runner/Base.lproj/Main.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/ios/Runner/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | $(DEVELOPMENT_LANGUAGE)
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | flutter_design
15 | CFBundlePackageType
16 | APPL
17 | CFBundleShortVersionString
18 | $(FLUTTER_BUILD_NAME)
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | $(FLUTTER_BUILD_NUMBER)
23 | LSRequiresIPhoneOS
24 |
25 | UILaunchStoryboardName
26 | LaunchScreen
27 | UIMainStoryboardFile
28 | Main
29 | UISupportedInterfaceOrientations
30 |
31 | UIInterfaceOrientationPortrait
32 | UIInterfaceOrientationLandscapeLeft
33 | UIInterfaceOrientationLandscapeRight
34 |
35 | UISupportedInterfaceOrientations~ipad
36 |
37 | UIInterfaceOrientationPortrait
38 | UIInterfaceOrientationPortraitUpsideDown
39 | UIInterfaceOrientationLandscapeLeft
40 | UIInterfaceOrientationLandscapeRight
41 |
42 | UIViewControllerBasedStatusBarAppearance
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/ios/Runner/Runner-Bridging-Header.h:
--------------------------------------------------------------------------------
1 | #import "GeneratedPluginRegistrant.h"
2 |
--------------------------------------------------------------------------------
/lib/constant/color_const.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 |
3 | /// Created by NieBin on 2020-03-16
4 | /// Github: https://github.com/nb312
5 | /// Email: niebin312@gmail.com
6 |
7 | class ColorConst{
8 | static const Color WHITE = Colors.white;
9 |
10 | static const Color STATE_COLOR = Colors.white;
11 | static const Color BUTTON_COLOR = Color(0xFF01C2C3);
12 | static const Color BACKGROUND = Colors.black;
13 | static const Color ITEM_BACK = Colors.white;
14 | static const Color TRANSPARENT = Colors.transparent;
15 |
16 | ///背景颜色
17 | static const Color BG_NORMAL = Color(0x1F000000);
18 | static const Color BG_DISABLE = Color(0xFF757575);
19 | static const Color BG_GREY = Color(0xFFF5F5F9);
20 | static const Color BG_GREY_LIGHT = Color(0xFFF7F7F7);
21 | static const Color BG_BLUE = Color(0xFF01C2C3);
22 | static const Color BG_RED = Color(0xFFFF4556);
23 | static const Color BG_LIGHT_BLUE = Color(0xFFEEF9F9);
24 |
25 | ///横线颜色
26 | static const Color LINE_NORMAL = Color(0xFFEEEEEE);
27 |
28 | ///边框颜色
29 | static const Color BORDER_GRAY = Color(0xFFAAAABB);
30 |
31 | ///字体颜色
32 | static const Color TEXT_TITLE = Colors.black;
33 | static const Color TEXT_BLACK = Color(0xFF14151A);
34 | static const Color TEXT_CONTENT = Color(0xFF5A5F6D);
35 | static const Color TEXT_HINT = Color(0x42000000);
36 | static const Color TEXT_WARN = Color(0xFFEF5350);
37 | static const Color TEXT_GRAY_DEEPEN = Color(0xFF5A5F6D);
38 | static const Color TEXT_GRAY = Color(0xFFAAAABB);
39 | static const Color TEXT_BLUE = Color(0xFF01C2C3);
40 | }
--------------------------------------------------------------------------------
/lib/constant/page_const.dart:
--------------------------------------------------------------------------------
1 | /// Created by NieBin on 2020-03-16
2 | /// Github: https://github.com/nb312
3 | /// Email: niebin312@gmail.com
4 | class PageConst {
5 | static const String HOME_PAGE = "/home";
6 | static const String FACTORY_PAGE = "/factory"; //工厂模式
7 | static const String INSTANCE_PAGE = "/instance"; //单例
8 | static const String BUILD_PAGE = "/build"; //建造者模式
9 | static const String PROTOTYPE_PAGE = "/prototype"; //原型模式
10 | static const String ADAPTER_PAGE = "/adapter"; //适配器模式
11 | static const String BRIDGE_PAGE = "/bridge"; //桥接模式
12 | static const String FILTER_PAGE = "/filter"; //过滤器模式或标准模式
13 | static const String COMPOSITE_PAGE = "/composite"; //组合模式
14 | static const String DECORATOR_PAGE = "/decorator"; //装饰者模式
15 | static const String FACADE_PAGE = "/facade"; //外观模式
16 | static const String FLYWEIGHT_PAGE = "/flyweight"; //享元模式
17 | static const String PROXY_PAGE = "/proxy"; //代理模式
18 | static const String CHAIN_PAGE = "/chain"; //享元模式
19 | static const String COMMAND_PAGE = "/command"; //命令模式
20 | static const String INTERPRETER_PAGE = "/interpreter"; //解释器模式
21 | static const String DUTY_PAGE = "/duty"; //责任链模式
22 | static const String MEDIATOR_PAGE = "/mediator"; //中介者模式
23 | static const String MEMENTO_PAGE = "/memento"; //备忘录模式
24 | static const String OBSERVER_PAGE = "/observer"; //观察者模式
25 | static const String STATE_PAGE = "/state"; //状态模式
26 | static const String NULL_PAGE = "/null"; //空对象模式
27 | static const String STRATEGY_PAGE = "/strategy"; //策略模式
28 | static const String TEMPLATE_PAGE = "/template"; //模版模式
29 | static const String VISITOR_PAGE = "/vistor"; //访问者模式
30 | static const String MVC_PAGE = "/mvc"; //mvc模式
31 | static const String ITERATOR_PAGE = "/iterator"; //迭代器模式
32 | static const String BUSINESS_DELEGATE_PAGE = "/business/delegate"; //模式
33 | }
34 |
--------------------------------------------------------------------------------
/lib/constant/string_const.dart:
--------------------------------------------------------------------------------
1 | /// Created by NieBin on 2020-03-16
2 | /// Github: https://github.com/nb312
3 | /// Email: niebin312@gmail.com
4 | ///字符串常量
5 | class StringConst {
6 | static const String APP_NAME = "设计模式";
7 |
8 | ///工厂模式
9 | static const String FACTORY_ = "工厂模式";
10 |
11 | //单例模式
12 | static const String SINGLE_ = "单例模式";
13 |
14 | //建造者模式
15 | static const String BUILDER_ = "建造者模式";
16 |
17 | //原型模式
18 | static const String PROTOTYPE_ = "原型模式";
19 |
20 | //适配器模式
21 | static const String ADAPTER_ = "适配器模式";
22 |
23 | //桥接模式
24 | static const String BRIDGE_ = "桥接模式";
25 |
26 | //过滤器/标准模式
27 | static const String FILTER_ = "过滤器/标准模式";
28 |
29 | //组合模式
30 | static const String COMBINATION_ = "组合模式";
31 |
32 | //装饰者模式
33 | static const String DECORATOR_ = "装饰者模式";
34 |
35 | //外观模式
36 | static const String FACADE_ = "外观模式";
37 |
38 | //享元模式
39 | static const String FLYWEIGHT_ = "享元模式";
40 |
41 | //享元模式
42 | static const String PROXY_ = "代理模式";
43 |
44 | //享元模式
45 | static const String DUTY_ = "责任链模式";
46 |
47 | //命令模式
48 | static const String COMMAND_ = "命令模式";
49 |
50 | //解释器模式
51 | static const String INTERPRETER_ = "解释器模式";
52 |
53 | //迭代器模式
54 | static const String ITERATOR_ = "迭代器模式";
55 |
56 | //迭代器模式
57 | static const String MID_ = "中介者模式";
58 |
59 | //备忘录模式
60 | static const String MEMORY_ = "备忘录模式";
61 |
62 | //观察者模式
63 | static const String OBSERVER_ = "观察者模式";
64 |
65 | //状态模式
66 | static const String STATE_ = "状态模式";
67 |
68 | //策略模式
69 | static const String STRATEGY_ = "策略模式";
70 |
71 | //模版模式
72 | static const String TEMPLATE_ = "模版模式";
73 | }
74 |
--------------------------------------------------------------------------------
/lib/main.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:flutter_design/constant/string_const.dart';
3 | import 'package:flutter_design/page/adapter/adapter_page.dart';
4 | import 'package:flutter_design/page/bridge/bridge_page.dart';
5 | import 'package:flutter_design/page/combination/combination_page.dart';
6 | import 'package:flutter_design/page/command/command_page.dart';
7 | import 'package:flutter_design/page/decorator/decorator_page.dart';
8 | import 'package:flutter_design/page/duty/duty_page.dart';
9 | import 'package:flutter_design/page/facade/facade_page.dart';
10 | import 'package:flutter_design/page/filter/filter_page.dart';
11 | import 'package:flutter_design/page/flyweight/flyweight_page.dart';
12 | import 'package:flutter_design/page/interpreter/intepreter_page.dart';
13 | import 'package:flutter_design/page/iterator/Iterator_page.dart';
14 | import 'package:flutter_design/page/memory/memory_page.dart';
15 | import 'package:flutter_design/page/midd/mid_page.dart';
16 | import 'package:flutter_design/page/observer/observer_page.dart';
17 | import 'package:flutter_design/page/proxy/proxy_page.dart';
18 | import 'package:flutter_design/page/state/state_page.dart';
19 | import 'package:flutter_design/page/strategy/strategy_page.dart';
20 | import 'package:flutter_design/page/template/template_page.dart';
21 |
22 | import 'constant/page_const.dart';
23 | import 'constant/string_const.dart';
24 | import 'page/_page.dart';
25 |
26 | ///{link https://www.runoob.com/design-pattern/design-pattern-tutorial.html}
27 | void main() => runApp(MyApp());
28 |
29 | class MyApp extends StatelessWidget {
30 | // This widget is the root of your application.
31 | @override
32 | Widget build(BuildContext context) {
33 | return MaterialApp(
34 | title: StringConst.APP_NAME,
35 | theme: ThemeData(
36 | primarySwatch: Colors.blue,
37 | ),
38 | home: HomePage(),
39 | routes: {
40 | PageConst.FACTORY_PAGE: (context) => FactoryPage(),
41 | PageConst.INSTANCE_PAGE: (context) => SinglePage(),
42 | PageConst.BUILD_PAGE: (context) => BuilderPage(),
43 | PageConst.PROTOTYPE_PAGE: (context) => PrototypePage(),
44 | PageConst.ADAPTER_PAGE: (context) => AdapterPage(),
45 | PageConst.BRIDGE_PAGE: (context) => BridgePage(),
46 | PageConst.FILTER_PAGE: (context) => FilterPage(),
47 | PageConst.COMPOSITE_PAGE: (context) => CombinationPage(),
48 | PageConst.DECORATOR_PAGE: (context) => DecoratorPage(),
49 | PageConst.FACADE_PAGE: (context) => FacadePage(),
50 | PageConst.FLYWEIGHT_PAGE: (context) => FlyweightPage(),
51 | PageConst.PROXY_PAGE: (context) => ProxyPage(),
52 | PageConst.DUTY_PAGE: (context) => DutyPage(),
53 | PageConst.COMMAND_PAGE: (context) => CommandPage(),
54 | PageConst.INTERPRETER_PAGE: (context) => InterpreterPage(),
55 | PageConst.ITERATOR_PAGE: (context) => IteratorPage(),
56 | PageConst.MEDIATOR_PAGE: (context) => MidPage(),
57 | PageConst.MEMENTO_PAGE: (context) => MemoryPage(),
58 | PageConst.OBSERVER_PAGE: (context) => ObserverPage(),
59 | PageConst.STATE_PAGE: (context) => StatePage(),
60 | PageConst.STRATEGY_PAGE: (context) => StrategyPage(),
61 | PageConst.TEMPLATE_PAGE: (context) => TemplatePage(),
62 | },
63 | );
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/lib/page/_page.dart:
--------------------------------------------------------------------------------
1 | /// Created by NieBin on 2020-03-16
2 | /// Github: https://github.com/nb312
3 | /// Email: niebin312@gmail.com
4 | export "factory/factory_page.dart";
5 | export 'home_page.dart';
6 | export 'single/single_page.dart';
7 | export 'builder/builder_page.dart';
8 | export 'prototype/prototype_page.dart';
9 |
--------------------------------------------------------------------------------
/lib/page/adapter/adapter_page.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:flutter_design/constant/string_const.dart';
3 | import 'package:flutter_design/page/adapter/adapter_target.dart';
4 | import 'package:flutter_design/page/adapter/gun.dart';
5 |
6 | /// Created by NieBin on 2020-03-18
7 | /// Github: https://github.com/nb312
8 | /// Email: niebin312@gmail.com
9 |
10 | class AdapterPage extends StatefulWidget {
11 | @override
12 | _AdapterPageState createState() => _AdapterPageState();
13 | }
14 |
15 | class _AdapterPageState extends State {
16 | @override
17 | Widget build(BuildContext context) {
18 | ITarget target = Adapter();
19 | return Scaffold(
20 | appBar: AppBar(
21 | title: Text(StringConst.ADAPTER_),
22 | ),
23 | body: Container(
24 | child: Column(
25 | children: [
26 | Text("接口adapter模式"),
27 | Container(
28 | color: Colors.grey,
29 | child: Padding(
30 | padding: const EdgeInsets.symmetric(horizontal: 20),
31 | child: Text(
32 | "适配内容 :${target.string()}",
33 | style: TextStyle(
34 | fontSize: 30,
35 | color: Colors.orange,
36 | fontWeight: FontWeight.bold),
37 | ),
38 | ),
39 | ),
40 | SizedBox(height: 20),
41 | Text("对象adapter模式"),
42 | FlatButton(
43 | color: Colors.redAccent,
44 | child: Padding(
45 | padding: const EdgeInsets.all(20.0),
46 | child: Text("点击看看log"),
47 | ),
48 | onPressed: () {
49 | //正常
50 | Gun gun = Gun();
51 | gun.mode = OldMode();
52 | gun.fire();
53 | //适配器
54 | ModeAdapter adapter = ModeAdapter();
55 | adapter.newMode = NewMode();
56 | gun.mode = adapter;
57 | gun.fire();
58 | },
59 | )
60 | ],
61 | ),
62 | ),
63 | );
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/lib/page/adapter/adapter_target.dart:
--------------------------------------------------------------------------------
1 | /// Created by NieBin on 2020-03-18
2 | /// Github: https://github.com/nb312
3 | /// Email: niebin312@gmail.com
4 | ///适配对象
5 | class Adaptee {
6 | String oldStr() {
7 | return "I come from old system,\nI donot know your language";
8 | }
9 | }
10 |
11 | //常规使用
12 | abstract class ITarget {
13 | String string();
14 | }
15 |
16 | class Adapter extends Adaptee implements ITarget {
17 | @override
18 | String string() {
19 | return oldStr();
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/lib/page/adapter/gun.dart:
--------------------------------------------------------------------------------
1 | /// Created by NieBin on 2020-03-20
2 | /// Github: https://github.com/nb312
3 | /// Email: niebin312@gmail.com
4 | /// 以下主要对象适配器的实例
5 | abstract class IOldMode {
6 | void fire();
7 | }
8 |
9 | class OldMode implements IOldMode {
10 | @override
11 | void fire() {
12 | print("发射20mm子弹");
13 | }
14 | }
15 |
16 | abstract class INewMode {
17 | void newFire();
18 | }
19 |
20 | class NewMode implements INewMode {
21 | @override
22 | void newFire() {
23 | print("发射两米长的大菜刀");
24 | }
25 | }
26 |
27 | class ModeAdapter implements IOldMode {
28 | INewMode _mode;
29 |
30 | set newMode(INewMode mode) => _mode = mode;
31 |
32 | @override
33 | void fire() {
34 | _mode.newFire();
35 | }
36 | }
37 |
38 | class Gun {
39 | IOldMode _mode;
40 |
41 | set mode(IOldMode mode) => _mode = mode;
42 |
43 | void fire() {
44 | _mode.fire();
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/lib/page/bridge/bridge_mode.dart:
--------------------------------------------------------------------------------
1 | /// Created by NieBin on 2020-03-20
2 | /// Github: https://github.com/nb312
3 | /// Email: niebin312@gmail.com
4 | abstract class ITransmission {
5 | void gear();
6 | }
7 |
8 | abstract class ICar {
9 | ITransmission _transmission;
10 |
11 | set transmission(ITransmission transmission) {
12 | _transmission = transmission;
13 | }
14 |
15 | void run();
16 | }
17 |
18 | class SmallCar extends ICar {
19 | @override
20 | void run() {
21 | _transmission.gear();
22 | print("启动小车");
23 | }
24 | }
25 |
26 | class LargeCar extends ICar {
27 | @override
28 | void run() {
29 | _transmission.gear();
30 | print("启动大车");
31 | }
32 | }
33 |
34 | class AutoTrans implements ITransmission {
35 | @override
36 | void gear() {
37 | print("切换到自动带");
38 | }
39 | }
40 |
41 | class ManualTrans implements ITransmission {
42 | @override
43 | void gear() {
44 | print("切换到手动档");
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/lib/page/bridge/bridge_page.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:flutter_design/constant/string_const.dart';
3 | import 'package:flutter_design/page/bridge/bridge_mode.dart';
4 |
5 | /// Created by NieBin on 2020-03-20
6 | /// Github: https://github.com/nb312
7 | /// Email: niebin312@gmail.com
8 |
9 | class BridgePage extends StatefulWidget {
10 | @override
11 | _BridgePageState createState() => _BridgePageState();
12 | }
13 |
14 | class _BridgePageState extends State {
15 | @override
16 | Widget build(BuildContext context) {
17 | return Scaffold(
18 | appBar: AppBar(
19 | title: Text(StringConst.BRIDGE_),
20 | ),
21 | body: Container(
22 | child: Column(
23 | mainAxisAlignment: MainAxisAlignment.start,
24 | crossAxisAlignment: CrossAxisAlignment.center,
25 | children: [
26 | Text("演示桥接模式"),
27 | FlatButton(
28 | color: Colors.brown,
29 | child: Padding(
30 | padding: const EdgeInsets.all(8.0),
31 | child: Text("启动小车"),
32 | ),
33 | onPressed: () {
34 | ///
35 | ICar small = SmallCar();
36 | small.transmission = AutoTrans();
37 | small.run();
38 | },
39 | ),
40 | SizedBox(
41 | height: 20,
42 | ),
43 | FlatButton(
44 | color: Colors.brown,
45 | child: Padding(
46 | padding: const EdgeInsets.all(8.0),
47 | child: Text("启动大车"),
48 | ),
49 | onPressed: () {
50 | ///
51 | ICar large = LargeCar();
52 | large.transmission = ManualTrans();
53 | large.run();
54 | },
55 | )
56 | ],
57 | ),
58 | ),
59 | );
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/lib/page/builder/book.dart:
--------------------------------------------------------------------------------
1 | /// Created by NieBin on 2020-03-17
2 | /// Github: https://github.com/nb312
3 | /// Email: niebin312@gmail.com
4 | class Book {
5 | String name;
6 | String content;
7 | int page;
8 | String author;
9 | String date;
10 | String address;
11 | String businessName;
12 | String phone;
13 | }
14 |
--------------------------------------------------------------------------------
/lib/page/builder/builder.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter_design/page/builder/book.dart';
2 |
3 | /// Created by NieBin on 2020-03-17
4 | /// Github: https://github.com/nb312
5 | /// Email: niebin312@gmail.com
6 | ///
7 | abstract class IBuilder {
8 | set name(String name);
9 |
10 | set page(int page);
11 |
12 | set address(String address);
13 |
14 | set phone(String phone);
15 |
16 | set date(String date);
17 |
18 | set content(String content);
19 |
20 | set author(String author);
21 |
22 | set businessName(String business);
23 |
24 | Book build();
25 | }
26 |
27 | class DuBuilder implements IBuilder {
28 | Book _book = Book();
29 |
30 | @override
31 | set address(String address) => _book.address = "$address";
32 |
33 | @override
34 | set author(String author) => _book.author = "独家-$author";
35 |
36 | @override
37 | Book build() => _book;
38 |
39 | @override
40 | set businessName(String business) => _book.businessName = business;
41 |
42 | @override
43 | set date(String date) => _book.date = date;
44 |
45 | @override
46 | set name(String name) => _book.name = name;
47 |
48 | @override
49 | set page(int page) => _book.page = page;
50 |
51 | @override
52 | set phone(String phone) => _book.phone = phone;
53 |
54 | @override
55 | set content(String content) {
56 | _book.content = "独家制作书籍,非卖品\n";
57 | _book.content += content;
58 | _book.content += "\n独家感谢你的阅读";
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/lib/page/builder/builder_page.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:flutter_design/constant/string_const.dart';
3 | import 'package:flutter_design/page/builder/builder.dart';
4 | import 'package:flutter_design/page/builder/director.dart';
5 |
6 | /// Created by NieBin on 2020-03-17
7 | /// Github: https://github.com/nb312
8 | /// Email: niebin312@gmail.com
9 | class BuilderPage extends StatefulWidget {
10 | @override
11 | _BuilderPageState createState() => _BuilderPageState();
12 | }
13 |
14 | class _BuilderPageState extends State {
15 | IBuilder _builder = DuBuilder();
16 | BusinessDirector _director;
17 |
18 | @override
19 | Widget build(BuildContext context) {
20 | if (_director == null) {
21 | _director = BusinessDirector(_builder);
22 | }
23 | return Scaffold(
24 | appBar: AppBar(
25 | title: Text(StringConst.BUILDER_),
26 | ),
27 | body: Container(
28 | child: Center(
29 | child: Text(
30 | _director.publish(
31 | "《春风20里》",
32 | "春回大地,万物复苏,又是一个可以做自己爱做的事情",
33 | "东边的小草",
34 | 1,
35 | "北国的最南端",
36 | "1234321",
37 | "月球出版社",
38 | ),
39 | ),
40 | ),
41 | ),
42 | );
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/lib/page/builder/director.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter_design/page/builder/builder.dart';
2 |
3 | import 'book.dart';
4 |
5 | /// Created by NieBin on 2020-03-17
6 | /// Github: https://github.com/nb312
7 | /// Email: niebin312@gmail.com
8 | ///排布build进行书籍书写
9 | class BusinessDirector {
10 | IBuilder _builder;
11 |
12 | BusinessDirector(this._builder);
13 |
14 | String publish(
15 | String name,
16 | String content,
17 | String author,
18 | int page,
19 | String address,
20 | String phone,
21 | String businessName,
22 | ) {
23 | _builder
24 | ..name = name
25 | ..author = author
26 | ..page = page
27 | ..address = address
28 | ..phone = phone
29 | ..content = content
30 | ..businessName = businessName;
31 | Book book = _builder.build();
32 | String b = "开始发布\n";
33 | b += "书名: ${book.name}\n";
34 | b += "作者: ${book.author}\n";
35 | b += "出版社名称:${book.businessName}\n";
36 | b += "地址:${book.address}\n";
37 | b += "电话:${book.phone}\n";
38 | b += "书内容: \n${book.content}\n";
39 | return b;
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/lib/page/combination/combination_mode.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/cupertino.dart';
2 |
3 | /// Created by NieBin on 2020-03-23
4 | /// Github: https://github.com/nb312
5 | /// Email: niebin312@gmail.com
6 |
7 | class Tree {
8 | double length;
9 | double radius;
10 | List _subTrees;
11 | double depth;
12 | String name;
13 |
14 | Tree(
15 | this.name,
16 | this.length,
17 | this.radius,
18 | this.depth,
19 | ) {
20 | _subTrees = List();
21 | }
22 |
23 | void addTree(Tree tree) {
24 | _subTrees?.add(tree);
25 | }
26 |
27 | void remove(Tree tree) {
28 | _subTrees?.remove(tree);
29 | }
30 |
31 | List get subTrees => _subTrees;
32 |
33 | @override
34 | String toString() {
35 | return "Tree(length:$length,rradius:$radius,depth:$depth) \n subTree.count=${_subTrees.length}";
36 | }
37 | }
38 |
39 | abstract class File {
40 | String name;
41 |
42 | File(this.name);
43 |
44 | void display();
45 | }
46 |
47 | class Folder extends File {
48 | List _files;
49 |
50 | Folder(String name) : super(name) {
51 | _files = List();
52 | }
53 |
54 | void add(File file) {
55 | _files.add(file);
56 | }
57 |
58 | void remove(File file) {
59 | _files.remove(file);
60 | }
61 |
62 | @override
63 | void display() {
64 | print("This is folder: $name");
65 | for (File f in _files) {
66 | f.display();
67 | }
68 | }
69 | }
70 |
71 | class TextFile extends File {
72 | TextFile(String name) : super(name);
73 |
74 | @override
75 | void display() {
76 | debugPrint("This is text file: $name");
77 | }
78 | }
79 |
80 | class JpgFile extends File {
81 | JpgFile(String name) : super(name);
82 |
83 | @override
84 | void display() {
85 | debugPrint("This is jpg file: $name");
86 | }
87 | }
88 |
89 | class VideoFile extends File {
90 | VideoFile(String name) : super(name);
91 |
92 | @override
93 | void display() {
94 | debugPrint("This is video file: $name");
95 | }
96 | }
97 |
--------------------------------------------------------------------------------
/lib/page/combination/combination_page.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:flutter_design/constant/string_const.dart';
3 | import 'package:flutter_design/page/combination/combination_mode.dart';
4 |
5 | /// Created by NieBin on 2020-03-23
6 | /// Github: https://github.com/nb312
7 | /// Email: niebin312@gmail.com
8 |
9 | class CombinationPage extends StatefulWidget {
10 | @override
11 | _CombinationPageState createState() => _CombinationPageState();
12 | }
13 |
14 | class _CombinationPageState extends State {
15 | Tree root;
16 |
17 | @override
18 | void initState() {
19 | initData();
20 | super.initState();
21 | }
22 |
23 | @override
24 | Widget build(BuildContext context) {
25 | return Scaffold(
26 | appBar: AppBar(
27 | title: Text(StringConst.COMBINATION_),
28 | ),
29 | body: Container(
30 | child: SingleChildScrollView(
31 | child: Column(
32 | children: _items(),
33 | ),
34 | ),
35 | ),
36 | floatingActionButton: FloatingActionButton(
37 | onPressed: () {
38 | Folder folder = Folder("设计文档");
39 | File txtFile = TextFile("readme.txt");
40 | File jpg = JpgFile("切图.jpg");
41 | File video = VideoFile("交互动画.mp4");
42 |
43 | folder.add(txtFile);
44 | folder.add(jpg);
45 | folder.add(video);
46 | folder.display();
47 | },
48 | child: Icon(Icons.refresh),
49 | ),
50 | );
51 | }
52 |
53 | List _items() {
54 | List list = List();
55 | list.add(_branchItem(root));
56 | for (Tree tree in root.subTrees) {
57 | list.add(Divider(
58 | color: Colors.blue,
59 | ));
60 | list.add(_branchItem(tree));
61 | }
62 | return list;
63 | }
64 |
65 | Widget _branchItem(Tree tree) => Container(
66 | child: Column(
67 | children: [
68 | Text("分支名: ${tree.name}"),
69 | Text("长度: ${tree.length}"),
70 | Text("有多粗: ${tree.radius}"),
71 | Text("深度: ${tree.depth}"),
72 | ],
73 | ),
74 | );
75 |
76 | void initData() {
77 | root = Tree("Root", 100, 10, 0);
78 | for (int i = 0; i < 10; i++) {
79 | root.addTree(Tree("Branch$i", 50, 5, 1));
80 | }
81 | print("Root:${root.toString()}");
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/lib/page/command/command_mode.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/cupertino.dart';
2 |
3 | /// Created by NieBin on 2020-03-31
4 | /// Github: https://github.com/nb312
5 | /// Email: niebin312@gmail.com
6 | //接收角色
7 | class AudioPlayer {
8 | void play() {
9 | debugPrint("播放音乐");
10 | }
11 |
12 | void stop() {
13 | debugPrint("停止播放音乐");
14 | }
15 |
16 | void pause() {
17 | debugPrint("暂停播放音乐");
18 | }
19 |
20 | void nextPlay() {
21 | debugPrint("播放下一首");
22 | }
23 | }
24 |
25 | //命令角色
26 | abstract class Command {
27 | void execute();
28 | }
29 |
30 | class PlayCommand implements Command {
31 | AudioPlayer player;
32 |
33 | PlayCommand(this.player);
34 |
35 | @override
36 | void execute() {
37 | player?.play();
38 | }
39 | }
40 |
41 | class StopCommand implements Command {
42 | AudioPlayer player;
43 |
44 | StopCommand(this.player);
45 |
46 | @override
47 | void execute() {
48 | player?.stop();
49 | }
50 | }
51 |
52 | class PauseCommand implements Command {
53 | AudioPlayer player;
54 |
55 | PauseCommand(this.player);
56 |
57 | @override
58 | void execute() {
59 | player?.pause();
60 | }
61 | }
62 |
63 | class NextCommand implements Command {
64 | AudioPlayer player;
65 |
66 | NextCommand(this.player);
67 |
68 | @override
69 | void execute() {
70 | player?.nextPlay();
71 | }
72 | }
73 |
74 | //手势调用命令
75 | class PointerInvoker {
76 | Command _command;
77 |
78 | set command(Command command) => _command = command;
79 |
80 | void execute() {
81 | _command.execute();
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/lib/page/command/command_page.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:flutter_design/constant/string_const.dart';
3 | import 'package:flutter_design/page/command/command_mode.dart';
4 |
5 | /// Created by NieBin on 2020-03-31
6 | /// Github: https://github.com/nb312
7 | /// Email: niebin312@gmail.com
8 |
9 | class CommandPage extends StatefulWidget {
10 | @override
11 | _CommandPageState createState() => _CommandPageState();
12 | }
13 |
14 | class _CommandPageState extends State {
15 | AudioPlayer _player;
16 |
17 | @override
18 | initState() {
19 | super.initState();
20 | _player = AudioPlayer();
21 | }
22 |
23 | @override
24 | Widget build(BuildContext context) {
25 | return Scaffold(
26 | appBar: AppBar(
27 | title: Text(StringConst.COMMAND_),
28 | ),
29 | body: Container(
30 | alignment: Alignment.center,
31 | child: Row(
32 | crossAxisAlignment: CrossAxisAlignment.center,
33 | mainAxisAlignment: MainAxisAlignment.center,
34 | children: [
35 | _button(
36 | icon: Icons.pause,
37 | callback: () {
38 | PointerInvoker invoker = PointerInvoker();
39 | invoker.command = PauseCommand(_player);
40 | invoker.execute();
41 | },
42 | color: Colors.red),
43 | _button(
44 | icon: Icons.stop,
45 | callback: () {
46 | PointerInvoker invoker = PointerInvoker();
47 | invoker.command = StopCommand(_player);
48 | invoker.execute();
49 | },
50 | color: Colors.red),
51 | _button(
52 | icon: Icons.play_arrow,
53 | callback: () {
54 | PointerInvoker invoker = PointerInvoker();
55 | invoker.command = PlayCommand(_player);
56 | invoker.execute();
57 | },
58 | color: Colors.red),
59 | _button(
60 | icon: Icons.skip_next,
61 | callback: () {
62 | PointerInvoker invoker = PointerInvoker();
63 | invoker.command = NextCommand(_player);
64 | invoker.execute();
65 | },
66 | color: Colors.green),
67 | ],
68 | ),
69 | ),
70 | );
71 | }
72 |
73 | Widget _button({
74 | IconData icon,
75 | VoidCallback callback,
76 | Color color = Colors.white,
77 | }) =>
78 | FlatButton(
79 | color: color,
80 | child: Padding(
81 | padding: const EdgeInsets.all(10.0),
82 | child: Icon(
83 | icon,
84 | size: 30,
85 | ),
86 | ),
87 | onPressed: callback,
88 | shape: CircleBorder(),
89 | );
90 | }
91 |
--------------------------------------------------------------------------------
/lib/page/decorator/decorator_mode.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/cupertino.dart';
2 |
3 | /// Created by NieBin on 2020-03-24
4 | /// Github: https://github.com/nb312
5 | /// Email: niebin312@gmail.com
6 | ///
7 |
8 | abstract class Building {
9 | String decorate();
10 | }
11 |
12 | class Paint implements Building {
13 | final Building building;
14 |
15 | Paint(this.building);
16 |
17 | @override
18 | String decorate() {
19 | return "1.${building.decorate()}";
20 | }
21 | }
22 |
23 | ///商业建筑
24 | class BusinessBuilding extends Building {
25 | @override
26 | String decorate() {
27 | return "装修商业楼";
28 | }
29 | }
30 |
31 | ///居民楼
32 | class PersonBuilding extends Building {
33 | @override
34 | String decorate() {
35 | return "装修居民楼";
36 | }
37 | }
38 |
39 | class RedPaint extends Paint {
40 | RedPaint(Building building) : super(building);
41 |
42 | @override
43 | String decorate() {
44 | return "${super.decorate()}\n 2.粉刷为红色";
45 | }
46 | }
47 |
48 | class GreenPaint extends Paint {
49 | GreenPaint(Building building) : super(building);
50 |
51 | @override
52 | String decorate() {
53 | return "${super.decorate()}\n 2.粉刷为绿色";
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/lib/page/decorator/decorator_page.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:flutter_design/constant/string_const.dart';
3 | import 'package:flutter_design/page/decorator/decorator_mode.dart';
4 |
5 | /// Created by NieBin on 2020-03-24
6 | /// Github: https://github.com/nb312
7 | /// Email: niebin312@gmail.com
8 |
9 | class DecoratorPage extends StatefulWidget {
10 | @override
11 | _DecoratorPageState createState() => _DecoratorPageState();
12 | }
13 |
14 | class _DecoratorPageState extends State {
15 | String businessStr = "";
16 | String personStr = "";
17 |
18 | bool isPersonEven = false;
19 | bool isBusinessEven = false;
20 |
21 | @override
22 | Widget build(BuildContext context) {
23 | return Scaffold(
24 | appBar: AppBar(
25 | title: Text(StringConst.DECORATOR_),
26 | ),
27 | body: Container(
28 | color: Colors.white,
29 | child: Row(
30 | children: [
31 | Expanded(
32 | child: Column(
33 | mainAxisAlignment: MainAxisAlignment.center,
34 | children: [
35 | Text(
36 | "$businessStr",
37 | style: TextStyle(
38 | color: isBusinessEven ? Colors.red : Colors.green,
39 | fontSize: 20,
40 | fontWeight: FontWeight.bold,
41 | ),
42 | ),
43 | SizedBox(
44 | height: 20,
45 | ),
46 | FlatButton(
47 | color: Colors.brown,
48 | onPressed: () {
49 | setState(() {
50 | isBusinessEven = !isBusinessEven;
51 | Paint p = isBusinessEven
52 | ? RedPaint(BusinessBuilding())
53 | : GreenPaint(BusinessBuilding());
54 | businessStr = p.decorate();
55 | });
56 | },
57 | child: Text(
58 | "装修商业楼",
59 | style: TextStyle(color: Colors.white),
60 | ),
61 | )
62 | ],
63 | ),
64 | ),
65 | Expanded(
66 | child: Column(
67 | mainAxisAlignment: MainAxisAlignment.center,
68 | children: [
69 | Text(
70 | "$personStr",
71 | style: TextStyle(
72 | color: isPersonEven ? Colors.red : Colors.green,
73 | fontSize: 20,
74 | fontWeight: FontWeight.bold,
75 | ),
76 | ),
77 | SizedBox(
78 | height: 20,
79 | ),
80 | FlatButton(
81 | color: Colors.brown,
82 | onPressed: () {
83 | setState(() {
84 | isPersonEven = !isPersonEven;
85 | Paint p = isPersonEven
86 | ? RedPaint(PersonBuilding())
87 | : GreenPaint(PersonBuilding());
88 | personStr = p.decorate();
89 | });
90 | },
91 | child: Text(
92 | "装修居民楼",
93 | style: TextStyle(color: Colors.white),
94 | ),
95 | )
96 | ],
97 | ),
98 | ),
99 | ],
100 | ),
101 | ),
102 | );
103 | }
104 | }
105 |
--------------------------------------------------------------------------------
/lib/page/duty/duty_mode.dart:
--------------------------------------------------------------------------------
1 | /// Created by NieBin on 2020-03-30
2 | /// Github: https://github.com/nb312
3 | /// Email: niebin312@gmail.com
4 | class MessageModel {
5 | final String message;
6 | final int level;
7 |
8 | MessageModel(this.message, this.level);
9 | }
10 |
11 | abstract class IHandler {
12 | static const int LEVEL_ONE = 1;
13 | static const int LEVEL_TWO = 2;
14 | static const int LEVEL_THREE = 3;
15 | int level = LEVEL_ONE;
16 | IHandler _nextHandler;
17 |
18 | IHandler(this.level);
19 |
20 | set nextHandler(IHandler handler) => _nextHandler = handler;
21 |
22 | void sendMessage(MessageModel model);
23 |
24 | void hand(MessageModel model) {
25 | if (model.level == level) {
26 | this.sendMessage(model);
27 | } else {
28 | if (_nextHandler != null) {
29 | print("正在发送到下一级");
30 | _nextHandler.hand(model);
31 | } else {
32 | //实在找不到人,先改下
33 | print("已经到达顶级了");
34 | this.sendMessage(model);
35 | }
36 | }
37 | }
38 | }
39 |
40 | class EarthHandler extends IHandler {
41 | EarthHandler() : super(IHandler.LEVEL_ONE);
42 |
43 | @override
44 | void sendMessage(MessageModel model) {
45 | print("我是地球,我已经收到: ${model.message}");
46 | }
47 | }
48 |
49 | class MoonHandler extends IHandler {
50 | MoonHandler() : super(IHandler.LEVEL_TWO);
51 |
52 | @override
53 | void sendMessage(MessageModel model) {
54 | print("我是月亮,我已经收到: ${model.message}");
55 | }
56 | }
57 |
58 | class SunHandler extends IHandler {
59 | SunHandler() : super(IHandler.LEVEL_THREE);
60 |
61 | @override
62 | void sendMessage(MessageModel model) {
63 | print("我是太阳,我已经收到: ${model.message}");
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/lib/page/duty/duty_page.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/cupertino.dart';
2 | import 'package:flutter/material.dart';
3 | import 'package:flutter_design/constant/string_const.dart';
4 | import 'package:flutter_design/page/duty/duty_mode.dart';
5 |
6 | /// Created by NieBin on 2020-03-30
7 | /// Github: https://github.com/nb312
8 | /// Email: niebin312@gmail.com
9 |
10 | class DutyPage extends StatefulWidget {
11 | @override
12 | _DutyPageState createState() => _DutyPageState();
13 | }
14 |
15 | class _DutyPageState extends State {
16 | IHandler _handler;
17 |
18 | @override
19 | Widget build(BuildContext context) {
20 | return Scaffold(
21 | appBar: AppBar(
22 | title: Text(StringConst.DUTY_),
23 | ),
24 | body: Container(
25 | constraints: BoxConstraints.expand(),
26 | child: Column(
27 | crossAxisAlignment: CrossAxisAlignment.center,
28 | mainAxisAlignment: MainAxisAlignment.center,
29 | children: [
30 | FlatButton(
31 | onPressed: () {
32 | if (_handler == null) {
33 | _handler = EarthHandler();
34 | IHandler moon = MoonHandler();
35 |
36 | IHandler sun = SunHandler();
37 | moon.nextHandler = sun;
38 | _handler.nextHandler = moon;
39 | print("初始化成功");
40 | } else {
41 | print("你已经初始化");
42 | }
43 | },
44 | color: Colors.yellow,
45 | child: Padding(
46 | padding: const EdgeInsets.all(10.0),
47 | child: Text("初始化"),
48 | ),
49 | ),
50 | SizedBox(height: 10),
51 | FlatButton(
52 | onPressed: () {
53 | MessageModel model = MessageModel("我爱地球", IHandler.LEVEL_ONE);
54 | _handler.hand(model);
55 | },
56 | color: Colors.green,
57 | child: Text("发送信息给地球"),
58 | ),
59 | SizedBox(height: 10),
60 | FlatButton(
61 | onPressed: () {
62 | MessageModel model = MessageModel("我爱月球", IHandler.LEVEL_TWO);
63 | _handler.hand(model);
64 | },
65 | color: Colors.blueGrey,
66 | child: Text("发送信息给月亮"),
67 | ),
68 | SizedBox(height: 10),
69 | FlatButton(
70 | onPressed: () {
71 | MessageModel model =
72 | MessageModel("我爱太阳", IHandler.LEVEL_THREE);
73 | _handler.hand(model);
74 | },
75 | color: Colors.red,
76 | child: Text("发送信息给太阳"),
77 | ),
78 | ],
79 | )),
80 | );
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/lib/page/facade/facade_model.dart:
--------------------------------------------------------------------------------
1 | /// Created by NieBin on 2020-03-25
2 | /// Github: https://github.com/nb312
3 | /// Email: niebin312@gmail.com
4 | abstract class IOTObject {
5 | void open();
6 | }
7 |
8 | class Light implements IOTObject {
9 | @override
10 | void open() {
11 | print("打开智能灯");
12 | }
13 | }
14 |
15 | class TV implements IOTObject {
16 | @override
17 | void open() {
18 | print("打开智能电视");
19 | }
20 | }
21 |
22 | class Door implements IOTObject {
23 | @override
24 | void open() {
25 | print("打开智能门");
26 | }
27 | }
28 |
29 | class FacadeManager {
30 | FacadeManager._();
31 |
32 | static FacadeManager _instance;
33 |
34 | static FacadeManager get instance => _getInstance();
35 |
36 | static FacadeManager _getInstance() {
37 | if (_instance == null) {
38 | _instance = FacadeManager._();
39 | }
40 | return _instance;
41 | }
42 |
43 | void open() {
44 | IOTObject light = Light();
45 | IOTObject tv = TV();
46 | IOTObject door = Door();
47 | light.open();
48 | tv.open();
49 | door.open();
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/lib/page/facade/facade_page.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:flutter_design/constant/string_const.dart';
3 | import 'package:flutter_design/page/facade/facade_model.dart';
4 |
5 | /// Created by NieBin on 2020-03-25
6 | /// Github: https://github.com/nb312
7 | /// Email: niebin312@gmail.com
8 |
9 | class FacadePage extends StatefulWidget {
10 | @override
11 | _FacadePageState createState() => _FacadePageState();
12 | }
13 |
14 | class _FacadePageState extends State {
15 | @override
16 | Widget build(BuildContext context) {
17 | return Scaffold(
18 | appBar: AppBar(
19 | title: Text(StringConst.FACADE_),
20 | ),
21 | body: Center(
22 | child: FlatButton(
23 | color: Colors.brown,
24 | onPressed: () {
25 | FacadeManager.instance.open();
26 | },
27 | child: Padding(
28 | padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 10),
29 | child: Text("紫妈开门"),
30 | ),
31 | ),
32 | ),
33 | );
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/lib/page/factory/color_concrete.dart:
--------------------------------------------------------------------------------
1 | /// Created by NieBin on 2020-03-16
2 | /// Github: https://github.com/nb312
3 | /// Email: niebin312@gmail.com
4 |
5 | abstract class IColor {
6 | void fill();
7 | }
8 |
9 | class Red implements IColor {
10 | @override
11 | void fill() {
12 | print("this color is Red");
13 | }
14 | }
15 |
16 | class Green implements IColor {
17 | @override
18 | void fill() {
19 | print("this color is Green");
20 | }
21 | }
22 |
23 | class Yellow implements IColor {
24 | @override
25 | void fill() {
26 | print("this color is Yellow");
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/lib/page/factory/describe_text.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:flutter_design/constant/color_const.dart';
3 |
4 | /// Created by NieBin on 2020-03-16
5 | /// Github: https://github.com/nb312
6 | /// Email: niebin312@gmail.
7 | //
8 | abstract class IPlatformDescribeText {
9 | Widget text(String content);
10 | }
11 |
12 | class AndroidDescribeText implements IPlatformDescribeText {
13 | @override
14 | Widget text(String content) => Card(
15 | child: Center(
16 | child: Text(
17 | content,
18 | style: TextStyle(
19 | fontSize: 16, color: Colors.green, fontWeight: FontWeight.bold),
20 | ),
21 | ),
22 | );
23 | }
24 |
25 | class IosDescribeText implements IPlatformDescribeText {
26 | @override
27 | Widget text(String content) => Card(
28 | elevation: 10,
29 | child: Center(
30 | child: Text(
31 | content,
32 | style: TextStyle(
33 | fontSize: 16, color: Colors.red, fontWeight: FontWeight.w100),
34 | ),
35 | ),
36 | );
37 | }
38 |
39 | class WebDescribeText implements IPlatformDescribeText {
40 | @override
41 | Widget text(String content) => Card(
42 | elevation: 4,
43 | child: Center(
44 | child: Text(
45 | content,
46 | style: TextStyle(fontSize: 16, color: Colors.purple),
47 | ),
48 | ),
49 | );
50 | }
51 |
--------------------------------------------------------------------------------
/lib/page/factory/factory_abstract.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter_design/page/factory/color_concrete.dart';
2 | import 'package:flutter_design/page/factory/shape_concrete.dart';
3 |
4 | /// Created by NieBin on 2020-03-16
5 | /// Github: https://github.com/nb312
6 | /// Email: niebin312@gmail.com
7 | enum ColorType { Red, Green, Yellow }
8 | enum ShapeType { Rectangle, Circle, Triangle }
9 |
10 | ///示列 抽象工厂
11 | abstract class IFactory {
12 | IShape getShape(ShapeType type);
13 |
14 | IColor getColor(ColorType type);
15 | }
16 |
17 | class _ColorFactory implements IFactory {
18 | @override
19 | IColor getColor(ColorType type) {
20 | switch (type) {
21 | case ColorType.Green:
22 | return Green();
23 | case ColorType.Yellow:
24 | return Yellow();
25 | case ColorType.Red:
26 | return Red();
27 | default:
28 | return Red();
29 | }
30 | }
31 |
32 | @override
33 | IShape getShape(ShapeType type) {
34 | return null;
35 | }
36 | }
37 |
38 | class _ShapeFactory implements IFactory {
39 | @override
40 | IColor getColor(ColorType type) {
41 | return null;
42 | }
43 |
44 | @override
45 | IShape getShape(ShapeType type) {
46 | switch (type) {
47 | case ShapeType.Circle:
48 | return Circle();
49 | case ShapeType.Rectangle:
50 | return Rectangle();
51 | case ShapeType.Triangle:
52 | return Triangle();
53 | default:
54 | return Circle();
55 | }
56 | }
57 | }
58 |
59 | //选择工厂类型
60 | enum FType { Color, Shape }
61 |
62 | //工厂类的工厂类
63 | class FactoryProducer {
64 | static IFactory createFactory(FType type) {
65 | switch (type) {
66 | case FType.Color:
67 | return _ColorFactory();
68 | case FType.Shape:
69 | return _ShapeFactory();
70 | default:
71 | return _ColorFactory();
72 | }
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/lib/page/factory/factory_concrete.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:flutter_design/page/factory/describe_text.dart';
3 |
4 | /// Created by NieBin on 2020-03-16
5 | /// Github: https://github.com/nb312
6 | /// Email: niebin312@gmail.com
7 | enum P { Android, Ios, Web }
8 |
9 | //普通工厂写法
10 | class DesFactory {
11 | static IPlatformDescribeText createPlatformText(P p) {
12 | switch (p) {
13 | case P.Android:
14 | return AndroidDescribeText();
15 | case P.Ios:
16 | return IosDescribeText();
17 | case P.Web:
18 | return WebDescribeText();
19 | default:
20 | return AndroidDescribeText();
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/lib/page/factory/factory_page.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:flutter_design/page/factory/color_concrete.dart';
3 | import 'package:flutter_design/page/factory/factory_abstract.dart';
4 | import 'package:flutter_design/page/factory/factory_concrete.dart';
5 | import 'package:flutter_design/page/factory/shape_concrete.dart';
6 |
7 | import '../../constant/string_const.dart';
8 |
9 | /// Created by NieBin on 2020-03-16
10 | /// Github: https://github.com/nb312
11 | /// Email: niebin312@gmail.com
12 | class FactoryPage extends StatefulWidget {
13 | @override
14 | _FactoryPageState createState() => _FactoryPageState();
15 | }
16 |
17 | class _FactoryPageState extends State {
18 | @override
19 | Widget build(BuildContext context) {
20 | return Scaffold(
21 | appBar: AppBar(
22 | title: Text(StringConst.FACTORY_),
23 | ),
24 | body: Container(
25 | child: Column(
26 | children: [
27 | Container(
28 | color: Colors.red,
29 | padding: EdgeInsets.symmetric(vertical: 10),
30 | margin: EdgeInsets.symmetric(vertical: 10),
31 | child: Center(
32 | child: Text(
33 | "下面是普通工厂的演示",
34 | style: TextStyle(color: Colors.white),
35 | ),
36 | ),
37 | ),
38 | Text("Android"),
39 | Divider(
40 | height: 1,
41 | ),
42 | Container(
43 | constraints: BoxConstraints.expand(height: 50),
44 | child:
45 | DesFactory.createPlatformText(P.Android).text("我是Android的描述"),
46 | ),
47 | Text("Ios"),
48 | Divider(
49 | height: 1,
50 | ),
51 | Container(
52 | constraints: BoxConstraints.expand(height: 50),
53 | child: DesFactory.createPlatformText(P.Ios).text("我是Ios的描述"),
54 | ),
55 | Text("Web"),
56 | Divider(
57 | height: 1,
58 | ),
59 | Container(
60 | constraints: BoxConstraints.expand(height: 50),
61 | child: DesFactory.createPlatformText(P.Web).text("我是Web的描述"),
62 | ),
63 | Container(
64 | color: Colors.brown,
65 | padding: EdgeInsets.symmetric(vertical: 10),
66 | margin: EdgeInsets.symmetric(vertical: 10),
67 | child: Center(
68 | child: Text(
69 | "下面是抽象工厂的演示",
70 | style: TextStyle(color: Colors.white),
71 | ),
72 | ),
73 | ),
74 | FlatButton(
75 | child: Text(
76 | "点击一下看看打印日志",
77 | style: TextStyle(color: Colors.white),
78 | ),
79 | color: Colors.brown,
80 | onPressed: () {
81 | //获取颜色工厂
82 | IFactory colorFactory =
83 | FactoryProducer.createFactory(FType.Color);
84 | IColor color = colorFactory.getColor(ColorType.Yellow);
85 | color.fill();
86 |
87 | //创建形状的工厂实例
88 | IFactory shapeFactory =
89 | FactoryProducer.createFactory(FType.Shape);
90 | IShape shape = shapeFactory.getShape(ShapeType.Triangle);
91 | shape.draw();
92 | },
93 | )
94 | ],
95 | ),
96 | ),
97 | );
98 | }
99 | }
100 |
--------------------------------------------------------------------------------
/lib/page/factory/shape_concrete.dart:
--------------------------------------------------------------------------------
1 | /// Created by NieBin on 2020-03-16
2 | /// Github: https://github.com/nb312
3 | /// Email: niebin312@gmail.com
4 | abstract class IShape {
5 | void draw();
6 | }
7 |
8 | class Rectangle implements IShape {
9 | @override
10 | void draw() {
11 | print("draw rectangle");
12 | }
13 | }
14 |
15 | class Circle implements IShape {
16 | @override
17 | void draw() {
18 | print("draw circle");
19 | }
20 | }
21 |
22 | class Triangle implements IShape {
23 | @override
24 | void draw() {
25 | print("draw triangle");
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/lib/page/filter/filter_mode.dart:
--------------------------------------------------------------------------------
1 | /// Created by NieBin on 2020-03-22
2 | /// Github: https://github.com/nb312
3 | /// Email: niebin312@gmail.com
4 | ///
5 | class Book {
6 | String name;
7 | String author;
8 | String type;
9 | String date;
10 |
11 | Book({
12 | this.name,
13 | this.author,
14 | this.type,
15 | this.date,
16 | });
17 | }
18 |
19 | abstract class ICondition {
20 | List filter(List source);
21 | }
22 |
23 | class PersonBookCondition implements ICondition {
24 | @override
25 | List filter(List source) {
26 | if (source == null || source.length == 0) return null;
27 | return source.where((element) => element.type == "person").toList();
28 | }
29 | }
30 |
31 | class MusicBookCondition implements ICondition {
32 | @override
33 | List filter(List source) {
34 | if (source == null || source.length == 0)
35 | return null;
36 | else
37 | return source.where((element) => element.type == "music").toList();
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/lib/page/filter/filter_page.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:flutter_design/constant/string_const.dart';
3 | import 'package:flutter_design/page/filter/filter_mode.dart';
4 |
5 | /// Created by NieBin on 2020-03-22
6 | /// Github: https://github.com/nb312
7 | /// Email: niebin312@gmail.com
8 | ///过滤器模式
9 | class FilterPage extends StatefulWidget {
10 | @override
11 | _FilterPageState createState() => _FilterPageState();
12 | }
13 |
14 | class _FilterPageState extends State {
15 | List _books = List();
16 |
17 | @override
18 | void initState() {
19 | initData();
20 | super.initState();
21 | }
22 |
23 | @override
24 | Widget build(BuildContext context) {
25 | return Scaffold(
26 | appBar: AppBar(
27 | title: Text(StringConst.FILTER_),
28 | ),
29 | body: SingleChildScrollView(
30 | child: Column(
31 | children: _item(),
32 | ),
33 | ),
34 | );
35 | }
36 |
37 | List _item() {
38 | List list = List();
39 | List persons = _personList();
40 | list.add(Container(
41 | constraints: BoxConstraints.expand(height: 20),
42 | color: Colors.blueGrey,
43 | child: Text(
44 | "人物分类",
45 | style: TextStyle(
46 | fontSize: 16, color: Colors.white, fontWeight: FontWeight.bold),
47 | ),
48 | ));
49 | for (Book b in persons) {
50 | list.add((_bookItem(b)));
51 | }
52 | list.add(SizedBox(height: 10));
53 | list.add(Container(
54 | constraints: BoxConstraints.expand(height: 20),
55 | color: Colors.blueGrey,
56 | child: Text(
57 | "音乐分类",
58 | style: TextStyle(
59 | fontSize: 16, color: Colors.white, fontWeight: FontWeight.bold),
60 | ),
61 | ));
62 | List musics = _musicList();
63 | for (Book b in musics) {
64 | list.add((_bookItem(b)));
65 | }
66 | return list;
67 | }
68 |
69 | Widget _bookItem(Book book) => Card(
70 | elevation: 4,
71 | child: Container(
72 | constraints: BoxConstraints.expand(height: 80),
73 | child: Column(
74 | children: [
75 | Text("书名: ${book.name}"),
76 | Text("作者: ${book.author}"),
77 | Text("作品类型: ${book.type == "person" ? "人物" : "音乐"}"),
78 | Text("发布日期: ${book.date}")
79 | ],
80 | ),
81 | ),
82 | );
83 |
84 | //过滤人
85 | List _personList() {
86 | ICondition condition = PersonBookCondition();
87 | return condition.filter(_books);
88 | }
89 |
90 | //过滤音乐
91 | List _musicList() {
92 | ICondition condition = MusicBookCondition();
93 | return condition.filter(_books);
94 | }
95 |
96 | void initData() {
97 | _books.add(
98 | Book(name: "肖申克的救赎", author: "弗兰克·达拉邦特", type: "person", date: "2015"));
99 |
100 | _books.add(
101 | Book(name: "人类简史", author: "尤瓦尔·赫拉利", type: "person", date: "2014"));
102 | _books.add(Book(name: "黛玉专", author: "林海", type: "music", date: "2014"));
103 | _books.add(
104 | Book(name: "时间的秩序", author: "卡洛·罗韦利", type: "person", date: "2019"));
105 | _books.add(Book(name: "北方的女王", author: "绕十三", type: "music", date: "2020"));
106 | _books
107 | .add(Book(name: "小王子", author: "圣埃克苏佩里", type: "person", date: "2003"));
108 |
109 | _books
110 | .add(Book(name: "只想要太阳的你", author: "张特", type: "music", date: "2020"));
111 | }
112 | }
113 |
--------------------------------------------------------------------------------
/lib/page/flyweight/flyweight_mode.dart:
--------------------------------------------------------------------------------
1 | import 'dart:collection';
2 |
3 | import 'package:flutter/material.dart';
4 |
5 | /// Created by NieBin on 2020-03-26
6 | /// Github: https://github.com/nb312
7 | /// Email: niebin312@gmail.com
8 | abstract class Clock {
9 | Color color;
10 |
11 | Widget display();
12 | }
13 |
14 | class PinkClock implements Clock {
15 | @override
16 | Color color = Colors.pink;
17 |
18 | @override
19 | Widget display() => Container(
20 | width: 100,
21 | height: 100,
22 | decoration: BoxDecoration(
23 | shape: BoxShape.rectangle,
24 | border: Border.all(color: Colors.green),
25 | color: color,
26 | ),
27 | child: Center(child: Text(DateTime.now().toIso8601String())),
28 | );
29 | }
30 |
31 | class GreenClock implements Clock {
32 | @override
33 | Color color = Colors.green;
34 |
35 | @override
36 | Widget display() => Container(
37 | width: 200,
38 | height: 100,
39 | decoration: BoxDecoration(shape: BoxShape.circle, color: color),
40 | child: Center(child: Text(DateTime.now().toIso8601String())),
41 | );
42 | }
43 |
44 | class BlueClock implements Clock {
45 | @override
46 | Color color = Colors.blue;
47 |
48 | @override
49 | Widget display() => Container(
50 | width: 150,
51 | height: 150,
52 | decoration: BoxDecoration(shape: BoxShape.circle, color: color),
53 | child: Center(child: Text(DateTime.now().toIso8601String())),
54 | );
55 | }
56 |
57 | class WhiteClock implements Clock {
58 | @override
59 | Color color = Colors.white;
60 |
61 | @override
62 | Widget display() => Container(
63 | width: 100,
64 | height: 100,
65 | decoration: BoxDecoration(
66 | shape: BoxShape.rectangle,
67 | color: color,
68 | border: Border.all(color: Colors.orangeAccent)),
69 | child: Center(child: Text(DateTime.now().toIso8601String())),
70 | );
71 | }
72 |
73 | class ClockManager {
74 | static Map _clocks = HashMap();
75 |
76 | static Clock getColorClock(String color) {
77 | if (_clocks.containsKey(color)) {
78 | return _clocks[color];
79 | } else {
80 | _clocks.putIfAbsent(color, () {
81 | if (color.toLowerCase() == "pink") {
82 | return PinkClock();
83 | } else if (color.toLowerCase() == "green") {
84 | return GreenClock();
85 | } else if (color.toLowerCase() == "blue") {
86 | return BlueClock();
87 | } else {
88 | return WhiteClock();
89 | }
90 | });
91 | return _clocks[color];
92 | }
93 | }
94 |
95 | static Clock removeClock(String color) {
96 | if (_clocks.containsKey(color)) {
97 | return _clocks.remove(color);
98 | } else {
99 | return null;
100 | }
101 | }
102 |
103 | static void clearAll() {
104 | _clocks.clear();
105 | }
106 | }
107 |
--------------------------------------------------------------------------------
/lib/page/flyweight/flyweight_page.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:flutter_design/constant/string_const.dart';
3 | import 'package:flutter_design/page/flyweight/flyweight_mode.dart';
4 |
5 | /// Created by NieBin on 2020-03-26
6 | /// Github: https://github.com/nb312
7 | /// Email: niebin312@gmail.com
8 |
9 | class FlyweightPage extends StatefulWidget {
10 | @override
11 | _FlyweightPageState createState() => _FlyweightPageState();
12 | }
13 |
14 | class _FlyweightPageState extends State {
15 | @override
16 | Widget build(BuildContext context) {
17 | return Scaffold(
18 | appBar: AppBar(
19 | title: Text(StringConst.FLYWEIGHT_),
20 | ),
21 | body: Container(
22 | child: Center(
23 | child: Column(
24 | mainAxisAlignment: MainAxisAlignment.center,
25 | crossAxisAlignment: CrossAxisAlignment.center,
26 | children: [
27 | ClockManager.getColorClock("pink").display(),
28 | SizedBox(height: 10,),
29 | ClockManager.getColorClock("green").display(),
30 | SizedBox(height: 10,),
31 | ClockManager.getColorClock("blue").display(),
32 | SizedBox(height: 10,),
33 | ClockManager.getColorClock("12423").display(),
34 | SizedBox(height: 10,)
35 | ],
36 | ),
37 | ),
38 | ),
39 | );
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/lib/page/home_page.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:flutter_design/constant/string_const.dart';
3 |
4 | import '../constant/page_const.dart';
5 | import '../constant/string_const.dart';
6 |
7 | /// Created by NieBin on 2020-03-16
8 | /// Github: https://github.com/nb312
9 | /// Email: niebin312@gmail.com
10 |
11 | class HomePage extends StatefulWidget {
12 | @override
13 | _HomePageState createState() => _HomePageState();
14 | }
15 |
16 | //参考链接
17 | Map map = {
18 | PageConst.FACTORY_PAGE: StringConst.FACTORY_,
19 | PageConst.INSTANCE_PAGE: StringConst.SINGLE_,
20 | PageConst.BUILD_PAGE: StringConst.BUILDER_,
21 | PageConst.PROTOTYPE_PAGE: StringConst.PROTOTYPE_,
22 | PageConst.ADAPTER_PAGE: StringConst.ADAPTER_,
23 | PageConst.BRIDGE_PAGE: StringConst.BRIDGE_,
24 | PageConst.FILTER_PAGE: StringConst.FILTER_,
25 | PageConst.COMPOSITE_PAGE: StringConst.COMBINATION_,
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 | PageConst.DUTY_PAGE: StringConst.DUTY_,
31 | PageConst.COMMAND_PAGE: StringConst.COMMAND_,
32 | PageConst.INTERPRETER_PAGE: StringConst.INTERPRETER_,
33 | PageConst.ITERATOR_PAGE: StringConst.ITERATOR_,
34 | PageConst.MEDIATOR_PAGE: StringConst.MID_,
35 | PageConst.MEMENTO_PAGE: StringConst.MEMORY_,
36 | PageConst.OBSERVER_PAGE: StringConst.OBSERVER_,
37 | PageConst.STATE_PAGE: StringConst.STATE_,
38 | PageConst.STRATEGY_PAGE: StringConst.STRATEGY_,
39 | PageConst.TEMPLATE_PAGE: StringConst.TEMPLATE_,
40 | };
41 |
42 | class _HomePageState extends State {
43 | @override
44 | Widget build(BuildContext context) {
45 | List items = List();
46 | List keys = map.keys.toList();
47 | for (int i = 0; i < map.length; i++) {
48 | String page = keys[i];
49 | String content = map[page];
50 | Widget w = _item(page: page, content: content);
51 | items.add(w);
52 | }
53 | return Scaffold(
54 | appBar: AppBar(
55 | title: Text(StringConst.APP_NAME),
56 | ),
57 | body: GridView.count(
58 | crossAxisCount: 2,
59 | childAspectRatio: 2,
60 | children: items,
61 | ),
62 | );
63 | }
64 |
65 | Widget _item({String content, String page}) => Container(
66 | child: InkWell(
67 | onTap: () {
68 | Navigator.of(context).pushNamed(page);
69 | },
70 | child: Card(
71 | elevation: 10,
72 | child: Center(
73 | child: Text(
74 | content,
75 | style: TextStyle(fontWeight: FontWeight.bold, fontSize: 16),
76 | ),
77 | ),
78 | ),
79 | ),
80 | );
81 | }
82 |
--------------------------------------------------------------------------------
/lib/page/interpreter/intepreter_page.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:flutter_design/constant/string_const.dart';
3 | import 'package:flutter_design/page/interpreter/interpreter_mode.dart';
4 |
5 | /// Created by NieBin on 2020-04-01
6 | /// Github: https://github.com/nb312
7 | /// Email: niebin312@gmail.com
8 |
9 | class InterpreterPage extends StatefulWidget {
10 | @override
11 | _InterpreterPageState createState() => _InterpreterPageState();
12 | }
13 |
14 | class _InterpreterPageState extends State {
15 | Value _value1 = Value(0);
16 | Value _value2 = Value(0);
17 | Add _add;
18 | Minus _minus;
19 | Multiple _multiply;
20 |
21 | @override
22 | Widget build(BuildContext context) {
23 | return Scaffold(
24 | appBar: AppBar(
25 | title: Text(StringConst.INTERPRETER_),
26 | ),
27 | body: Container(
28 | child: Column(
29 | mainAxisSize: MainAxisSize.min,
30 | children: [
31 | Row(
32 | mainAxisSize: MainAxisSize.min,
33 | children: [
34 | Padding(
35 | padding: const EdgeInsets.symmetric(horizontal: 10),
36 | child: Text("变量1"),
37 | ),
38 | Expanded(
39 | child: Container(
40 | constraints: BoxConstraints.expand(height: 40),
41 | child: TextFormField(
42 | onChanged: (v) {
43 | _value1 = Value(int.parse(v));
44 | },
45 | ),
46 | ),
47 | ),
48 | ],
49 | ),
50 | SizedBox(height: 10),
51 | Row(
52 | mainAxisSize: MainAxisSize.min,
53 | children: [
54 | Padding(
55 | padding: const EdgeInsets.symmetric(horizontal: 10),
56 | child: Text("变量2"),
57 | ),
58 | Expanded(
59 | child: Container(
60 | constraints: BoxConstraints.expand(height: 40),
61 | child: TextFormField(
62 | onChanged: (v) {
63 | _value2 = Value(int.parse(v));
64 | },
65 | ),
66 | ),
67 | ),
68 | ],
69 | ),
70 | SizedBox(height: 10),
71 | Container(
72 | height: 100,
73 | color: Colors.grey,
74 | padding: EdgeInsets.symmetric(horizontal: 10),
75 | child: Row(
76 | children: [
77 | FlatButton(
78 | child: Icon(Icons.add),
79 | color: Colors.white,
80 | onPressed: () {
81 | setState(() {
82 | print("v1=$_value1,v2=$_value2}");
83 | _add = Add(_value1, _value2);
84 | });
85 | },
86 | ),
87 | SizedBox(width: 10),
88 | Expanded(child: Text("加法=${_add?.interpret()}"))
89 | ],
90 | ),
91 | ),
92 | SizedBox(height: 10),
93 | Container(
94 | height: 100,
95 | padding: EdgeInsets.symmetric(horizontal: 10),
96 | color: Colors.brown,
97 | child: Row(
98 | children: [
99 | FlatButton(
100 | child: Icon(Icons.remove),
101 | color: Colors.white,
102 | onPressed: () {
103 | setState(() {
104 | print("v1=$_value1,v2=$_value2}");
105 | _minus = Minus(_value1, _value2);
106 | });
107 | },
108 | ),
109 | SizedBox(width: 10),
110 | Expanded(child: Text("减法=${_minus?.interpret()}"))
111 | ],
112 | ),
113 | ),
114 | SizedBox(height: 10),
115 | Container(
116 | height: 100,
117 | color: Colors.brown,
118 | padding: EdgeInsets.symmetric(horizontal: 10),
119 | child: Row(
120 | children: [
121 | FlatButton(
122 | child: Icon(Icons.clear),
123 | color: Colors.white,
124 | onPressed: () {
125 | setState(() {
126 | print("v1=$_value1,v2=$_value2}");
127 | _multiply = Multiple(_value1, _value2);
128 | });
129 | },
130 | ),
131 | SizedBox(width: 10),
132 | Expanded(child: Text("乘法=${_multiply?.interpret()}"))
133 | ],
134 | ),
135 | )
136 | ],
137 | ),
138 | ),
139 | );
140 | }
141 | }
142 |
--------------------------------------------------------------------------------
/lib/page/interpreter/interpreter_mode.dart:
--------------------------------------------------------------------------------
1 | /// Created by NieBin on 2020-04-01
2 | /// Github: https://github.com/nb312
3 | /// Email: niebin312@gmail.com
4 | abstract class Expression {
5 | int interpret();
6 | }
7 |
8 | class Value implements Expression {
9 | final int number;
10 |
11 | Value(this.number);
12 |
13 | @override
14 | int interpret() {
15 | return number;
16 | }
17 |
18 | @override
19 | String toString() {
20 | return "$number";
21 | }
22 | }
23 |
24 | class Add implements Expression {
25 | final Expression value1;
26 | final Expression value2;
27 |
28 | Add(this.value1, this.value2);
29 |
30 | @override
31 | int interpret() {
32 | return value1.interpret() + value2.interpret();
33 | }
34 | }
35 |
36 | class Minus implements Expression {
37 | final Expression value1;
38 | final Expression value2;
39 |
40 | Minus(this.value1, this.value2);
41 |
42 | @override
43 | int interpret() {
44 | return value1.interpret() - value2.interpret();
45 | }
46 | }
47 |
48 | class Multiple implements Expression {
49 | final Expression value1;
50 | final Expression value2;
51 |
52 | Multiple(this.value1, this.value2);
53 |
54 | @override
55 | int interpret() {
56 | return value1.interpret() * value2.interpret();
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/lib/page/iterator/Iterator_page.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:flutter_design/constant/string_const.dart';
3 | import 'package:flutter_design/page/iterator/iterator_mode.dart';
4 |
5 | /// Created by NieBin on 2020-04-02
6 | /// Github: https://github.com/nb312
7 | /// Email: niebin312@gmail.com
8 |
9 | class IteratorPage extends StatefulWidget {
10 | @override
11 | _IteratorPageState createState() => _IteratorPageState();
12 | }
13 |
14 | class _IteratorPageState extends State {
15 | final List _names = [
16 | "小明",
17 | "老张",
18 | "大黄",
19 | "嫦娥",
20 | "貂蝉",
21 | ];
22 | String _name = "待切换";
23 | Iterator _iterator;
24 | Aggregate _aggregate;
25 |
26 | @override
27 | void initState() {
28 | super.initState();
29 | _aggregate = NameAggregate(_names);
30 | _iterator = NameIterator(_aggregate);
31 | }
32 |
33 | @override
34 | Widget build(BuildContext context) {
35 | return Scaffold(
36 | appBar: AppBar(
37 | title: Text(StringConst.ITERATOR_),
38 | ),
39 | body: Container(
40 | child: Column(
41 | mainAxisAlignment: MainAxisAlignment.center,
42 | children: [
43 | Container(
44 | padding: EdgeInsets.symmetric(horizontal: 10),
45 | child: Row(
46 | mainAxisAlignment: MainAxisAlignment.spaceEvenly,
47 | mainAxisSize: MainAxisSize.min,
48 | children: _nameItems(),
49 | ),
50 | ),
51 | SizedBox(
52 | height: 10,
53 | ),
54 | Container(
55 | constraints: BoxConstraints.expand(height: 100),
56 | color: Colors.brown,
57 | child: Center(
58 | child: Text(_name),
59 | ),
60 | ),
61 | Row(
62 | mainAxisAlignment: MainAxisAlignment.center,
63 | children: [
64 | FlatButton(
65 | color: Colors.blueAccent,
66 | child: Padding(
67 | padding: const EdgeInsets.symmetric(horizontal: 10),
68 | child: Text("上一个"),
69 | ),
70 | onPressed: () {
71 | setState(() {
72 | _name = _iterator.prev() ?? "没有上一个";
73 | });
74 | },
75 | ),
76 | SizedBox(width: 10),
77 | FlatButton(
78 | child: Padding(
79 | padding: const EdgeInsets.symmetric(horizontal: 10),
80 | child: Text("下一个"),
81 | ),
82 | color: Colors.green,
83 | onPressed: () {
84 | setState(() {
85 | _name = _iterator.next() ?? "没有下一个";
86 | });
87 | },
88 | )
89 | ],
90 | ),
91 | ],
92 | ),
93 | ),
94 | );
95 | }
96 |
97 | List _nameItems() {
98 | List names = List();
99 | for (String name in _names) {
100 | names.add(_nameItem(name));
101 | names.add(SizedBox(width: 4));
102 | }
103 | return names;
104 | }
105 |
106 | Widget _nameItem(String name) => Container(
107 | color: Colors.grey,
108 | padding: EdgeInsets.symmetric(horizontal: 10),
109 | child: Text(
110 | name,
111 | style: TextStyle(fontSize: 20),
112 | ),
113 | );
114 | }
115 |
--------------------------------------------------------------------------------
/lib/page/iterator/iterator_mode.dart:
--------------------------------------------------------------------------------
1 | /// Created by NieBin on 2020-04-02
2 | /// Github: https://github.com/nb312
3 | /// Email: niebin312@gmail.com
4 | abstract class Iterator {
5 | bool hasNext();
6 |
7 | bool hasPrev();
8 |
9 | T next();
10 |
11 | T prev();
12 | }
13 |
14 | abstract class Aggregate {
15 | Iterator createIterator();
16 | }
17 |
18 | class NameIterator implements Iterator {
19 | int _index = 0;
20 | final NameAggregate name;
21 |
22 | NameIterator(this.name);
23 |
24 | @override
25 | bool hasNext() => _index < name.size && name.size > 0;
26 |
27 | @override
28 | String next() {
29 | if (hasNext()) {
30 | return name.getCurrentName(_index++);
31 | } else {
32 | return name.getCurrentName(name.size - 1);
33 | }
34 | }
35 |
36 | @override
37 | String prev() {
38 | if (hasPrev()) {
39 | return name.getCurrentName(_index--);
40 | } else {
41 | return name.getCurrentName(0);
42 | }
43 | }
44 |
45 | @override
46 | bool hasPrev() => _index <= name.size && _index > 0 && name.size > 0;
47 | }
48 |
49 | class NameAggregate implements Aggregate {
50 | final List names;
51 |
52 | NameAggregate(this.names);
53 |
54 | @override
55 | Iterator createIterator() {
56 | return NameIterator(this);
57 | }
58 |
59 | String getCurrentName(int index) {
60 | if (index < size) {
61 | return names[index];
62 | } else {
63 | return null;
64 | }
65 | }
66 |
67 | int get size => names.length;
68 | }
69 |
--------------------------------------------------------------------------------
/lib/page/memory/memory_mode.dart:
--------------------------------------------------------------------------------
1 | /// Created by NieBin on 2020-04-07
2 | /// Github: https://github.com/nb312
3 | /// Email: niebin312@gmail.com
4 | //记忆内容
5 | class Memory {
6 | String name;
7 | int age;
8 |
9 | @override
10 | String toString() {
11 | return "name: $name, age=$age";
12 | }
13 | }
14 |
15 | //记忆容器
16 | class MemoryContainer {
17 | Memory _memory;
18 |
19 | Memory get memory => _memory;
20 |
21 | set memory(Memory m) {
22 | this._memory = m;
23 | }
24 | }
25 |
26 | //恢复过程
27 | class XiaoMing {
28 | String name;
29 | int age;
30 |
31 | void restore(Memory memory) {
32 | this.name = memory.name;
33 | this.age = memory.age;
34 | }
35 |
36 | Memory createMemory() {
37 | Memory memory = Memory()
38 | ..name = this.name
39 | ..age = this.age;
40 | return memory;
41 | }
42 |
43 | @override
44 | String toString() {
45 | return "名字:$name, 年龄:$age";
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/lib/page/memory/memory_page.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:flutter_design/constant/string_const.dart';
3 | import 'package:flutter_design/page/memory/memory_mode.dart';
4 |
5 | /// Created by NieBin on 2020-04-07
6 | /// Github: https://github.com/nb312
7 | /// Email: niebin312@gmail.com
8 |
9 | class MemoryPage extends StatefulWidget {
10 | @override
11 | _MemoryPageState createState() => _MemoryPageState();
12 | }
13 |
14 | class _MemoryPageState extends State {
15 | String content;
16 |
17 | MemoryContainer _container;
18 | XiaoMing _xiaoMing;
19 |
20 | @override
21 | void initState() {
22 | _container = MemoryContainer();
23 | _xiaoMing = XiaoMing()
24 | ..name = "小名"
25 | ..age = 22;
26 | _container.memory = _xiaoMing.createMemory();
27 | }
28 |
29 | @override
30 | Widget build(BuildContext context) {
31 | return Scaffold(
32 | appBar: AppBar(
33 | title: Text(StringConst.MEMORY_),
34 | ),
35 | body: Container(
36 | child: Column(
37 | children: [
38 | Text(content ?? "待玩起来"),
39 | Text("记忆内容: ${_container.memory.toString()}"),
40 | SizedBox(height: 10),
41 | FlatButton(
42 | onPressed: () {
43 | setState(() {
44 | _container.memory = _xiaoMing.createMemory();
45 | });
46 | },
47 | color: Colors.pink,
48 | child: Padding(
49 | padding: const EdgeInsets.all(8.0),
50 | child: Text("用笔记一下"),
51 | ),
52 | ),
53 | SizedBox(height: 10),
54 | FlatButton(
55 | onPressed: () {
56 | _xiaoMing.age = _xiaoMing.age + 1;
57 | setState(() {
58 | content = _xiaoMing.toString();
59 | });
60 | },
61 | color: Colors.orange,
62 | child: Padding(
63 | padding: const EdgeInsets.all(8.0),
64 | child: Text("小名长大一岁"),
65 | ),
66 | ),
67 | FlatButton(
68 | onPressed: () {
69 | setState(() {
70 | _xiaoMing.restore(_container.memory);
71 | content = _xiaoMing.toString();
72 | });
73 | },
74 | color: Colors.green,
75 | child: Padding(
76 | padding: const EdgeInsets.all(8.0),
77 | child: Padding(
78 | padding: const EdgeInsets.all(8.0),
79 | child: Text("穿越到最年轻的时候"),
80 | ),
81 | ),
82 | ),
83 | ],
84 | ),
85 | ),
86 | );
87 | }
88 | }
89 |
--------------------------------------------------------------------------------
/lib/page/midd/mid_mode.dart:
--------------------------------------------------------------------------------
1 | /// Created by NieBin on 2020-04-05
2 | /// Github: https://github.com/nb312
3 | /// Email: niebin312@gmail.com
4 |
5 | ///普通类
6 | abstract class Student {
7 | String writeHomework(Teacher teacher, String content);
8 | }
9 |
10 | ///中介者
11 | abstract class Teacher {
12 | final Student smallMing;
13 | final Student oldWang;
14 |
15 | Teacher(this.smallMing, this.oldWang);
16 |
17 | String readSmallMing(String content);
18 |
19 | String readOldWang(String content);
20 | }
21 |
22 | ///小明
23 | class SmallMing extends Student {
24 | @override
25 | String writeHomework(Teacher teacher, String content) {
26 | return teacher.readSmallMing("小明写的内容: $content");
27 | }
28 | }
29 |
30 | ///隔壁老王
31 | class OldWang extends Student {
32 | @override
33 | String writeHomework(Teacher teacher, String content) {
34 | return teacher.readOldWang("老王写的内容: $content");
35 | }
36 | }
37 |
38 | class MathTeacher extends Teacher {
39 | MathTeacher(Student smallMing, Student oldWang) : super(smallMing, oldWang);
40 |
41 | @override
42 | String readOldWang(String content) {
43 | return "我正在看隔壁老王的作业: $content";
44 | }
45 |
46 | @override
47 | String readSmallMing(String content) {
48 | return "我正在看搞笑小明的作业: $content";
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/lib/page/midd/mid_page.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:flutter_design/constant/string_const.dart';
3 | import 'package:flutter_design/page/midd/mid_mode.dart';
4 |
5 | /// Created by NieBin on 2020-04-05
6 | /// Github: https://github.com/nb312
7 | /// Email: niebin312@gmail.com
8 | ///
9 | class MidPage extends StatefulWidget {
10 | @override
11 | _MidPageState createState() => _MidPageState();
12 | }
13 |
14 | class _MidPageState extends State {
15 | String _smallMing;
16 | String _wangContent;
17 | Student _small;
18 |
19 | Student _wang;
20 | Teacher _teacher;
21 |
22 | @override
23 | void initState() {
24 | super.initState();
25 | _small = SmallMing();
26 | _wang = OldWang();
27 | _teacher = MathTeacher(_small, _wang);
28 | }
29 |
30 | @override
31 | Widget build(BuildContext context) {
32 | return Scaffold(
33 | appBar: AppBar(
34 | title: Text(StringConst.MID_),
35 | ),
36 | body: Container(
37 | child: Row(
38 | children: [
39 | Expanded(
40 | child: Column(
41 | children: [
42 | Text(_smallMing ?? ""),
43 | FlatButton(
44 | child: Text("批改小明作业"),
45 | onPressed: () {
46 | setState(() {
47 | _smallMing = _small.writeHomework(
48 | _teacher, "认真写的数学作业${DateTime.now().toUtc()}");
49 | });
50 | },
51 | )
52 | ],
53 | ),
54 | ),
55 | Expanded(
56 | child: Column(
57 | children: [
58 | Text(_wangContent ?? ""),
59 | FlatButton(
60 | child: Text("批改老王作业"),
61 | onPressed: () {
62 | setState(() {
63 | _wangContent = _wang.writeHomework(
64 | _teacher, "认真写的数学作业${DateTime.now().toUtc()}");
65 | });
66 | },
67 | )
68 | ],
69 | ),
70 | ),
71 | ],
72 | ),
73 | ),
74 | );
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/lib/page/observer/observer_mode.dart:
--------------------------------------------------------------------------------
1 | /// Created by NieBin on 2020-04-13
2 | /// Github: https://github.com/nb312
3 | /// Email: niebin312@gmail.com
4 | abstract class ISubject {
5 | void attach(IObserver observer);
6 |
7 | void detach(IObserver observer);
8 |
9 | void detachAll();
10 |
11 | void notify();
12 | }
13 |
14 | class RealSubject extends ISubject {
15 | List _list;
16 | String _name;
17 |
18 | String get name => _name;
19 |
20 | set name(String n) {
21 | _name = n;
22 | notify();
23 | }
24 |
25 | RealSubject() {
26 | _list = List();
27 | }
28 |
29 | @override
30 | void attach(IObserver observer) {
31 | if (observer == null) return;
32 | if (!_list.contains(observer)) {
33 | _list.add(observer);
34 | }
35 | }
36 |
37 | @override
38 | void detach(IObserver observer) {
39 | if (_list.contains(observer)) {
40 | _list.remove(observer);
41 | }
42 | }
43 |
44 | @override
45 | void detachAll() {
46 | _list.clear();
47 | }
48 |
49 | @override
50 | void notify() {
51 | for (IObserver observer in _list) {
52 | observer.update(name);
53 | }
54 | }
55 | }
56 |
57 | abstract class IObserver {
58 | void update(String name);
59 | }
60 |
61 | class AObserver extends IObserver {
62 | String content;
63 |
64 | @override
65 | void update(String name) {
66 | print("我是A,收到外星人: $name");
67 | }
68 | }
69 |
70 | class BObserver extends IObserver {
71 | @override
72 | void update(String name) {
73 | print("我是B,收到一个东西: $name");
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/lib/page/observer/observer_page.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:flutter_design/page/observer/observer_mode.dart';
3 |
4 | /// Created by NieBin on 2020-04-13
5 | /// Github: https://github.com/nb312
6 | /// Email: niebin312@gmail.com
7 |
8 | class ObserverPage extends StatefulWidget {
9 | @override
10 | _ObserverPageState createState() => _ObserverPageState();
11 | }
12 |
13 | class _ObserverPageState extends State {
14 | List _observers;
15 | RealSubject _subject;
16 |
17 | @override
18 | void initState() {
19 | _observers = List();
20 | _subject = RealSubject();
21 | super.initState();
22 | }
23 |
24 | @override
25 | Widget build(BuildContext context) {
26 | return Scaffold(
27 | appBar: AppBar(
28 | title: Text("观察者模式"),
29 | ),
30 | body: Container(
31 | child: Column(
32 | children: [
33 | FlatButton(
34 | color: Colors.orange,
35 | child: Padding(
36 | padding: const EdgeInsets.all(8.0),
37 | child: Text("添加A型观察者"),
38 | ),
39 | onPressed: () {
40 | _subject.attach(AObserver());
41 | },
42 | ),
43 | SizedBox(height: 10),
44 | FlatButton(
45 | color: Colors.orange,
46 | child: Padding(
47 | padding: const EdgeInsets.all(8.0),
48 | child: Text("添加B型观察者"),
49 | ),
50 | onPressed: () {
51 | _subject.attach(BObserver());
52 | },
53 | ),
54 | SizedBox(height: 10),
55 | FlatButton(
56 | color: Colors.orange,
57 | child: Padding(
58 | padding: const EdgeInsets.all(8.0),
59 | child: Text("发个消息通知大家"),
60 | ),
61 | onPressed: () {
62 | _subject.name = "诸国缸体";
63 | _subject.notify();
64 | },
65 | ),
66 | ],
67 | ),
68 | ),
69 | );
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/lib/page/prototype/prototype_page.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:flutter_design/constant/string_const.dart';
3 | import 'package:flutter_design/page/prototype/prototype_product.dart';
4 |
5 | /// Created by NieBin on 2020-03-17
6 | /// Github: https://github.com/nb312
7 | /// Email: niebin312@gmail.com
8 | class PrototypePage extends StatefulWidget {
9 | @override
10 | _PrototypePageState createState() => _PrototypePageState();
11 | }
12 |
13 | class _PrototypePageState extends State {
14 | Product product = Product("苹果", "${DateTime.now().toUtc()}");
15 | String cloneStr = "";
16 |
17 | @override
18 | Widget build(BuildContext context) {
19 | return Scaffold(
20 | appBar: AppBar(
21 | title: Text(StringConst.PROTOTYPE_),
22 | ),
23 | body: Row(
24 | children: [
25 | Expanded(
26 | child: Column(
27 | children: [
28 | Expanded(
29 | child: Text(
30 | product.toString(),
31 | style: TextStyle(color: Colors.green , fontSize: 16),
32 | ),
33 | ),
34 | SizedBox(
35 | height: 100,
36 | ),
37 | FlatButton(
38 | color: Colors.green,
39 | onPressed: () {
40 | setState(() {
41 | product = Product("苹果", "${DateTime.now().toUtc()}");
42 | });
43 | },
44 | child: Text("创建产品"),
45 | ),
46 | SizedBox(
47 | height: 100,
48 | ),
49 | ],
50 | ),
51 | ),
52 | Expanded(
53 | child: Column(
54 | children: [
55 | Expanded(
56 | child: Text(
57 | cloneStr,
58 | style: TextStyle(color: Colors.orange, fontSize: 16),
59 | )),
60 | SizedBox(
61 | height: 100,
62 | ),
63 | FlatButton(
64 | color: Colors.orange,
65 | onPressed: () {
66 | setState(() {
67 | cloneStr = product.clone().toString();
68 | });
69 | },
70 | child: Text("克隆产品"),
71 | ),
72 | SizedBox(
73 | height: 100,
74 | ),
75 | ],
76 | ),
77 | ),
78 | ],
79 | ),
80 | );
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/lib/page/prototype/prototype_product.dart:
--------------------------------------------------------------------------------
1 | /// Created by NieBin on 2020-03-18
2 | /// Github: https://github.com/nb312
3 | /// Email: niebin312@gmail.com
4 | abstract class IClone {
5 | IClone clone();
6 | }
7 |
8 | class Product implements IClone {
9 | String name;
10 | String date;
11 |
12 | Product(this.name, this.date);
13 |
14 | @override
15 | IClone clone() {
16 | Product p = Product(this.name,this.date);
17 | return p;
18 | }
19 |
20 | @override
21 | String toString() {
22 | return " name: $name \n date: $date";
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/lib/page/proxy/proxy_mode.dart:
--------------------------------------------------------------------------------
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 | }
23 |
--------------------------------------------------------------------------------
/lib/page/proxy/proxy_page.dart:
--------------------------------------------------------------------------------
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 {
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 | }
39 |
--------------------------------------------------------------------------------
/lib/page/single/single_manager.dart:
--------------------------------------------------------------------------------
1 | /// Created by NieBin on 2020-03-16
2 | /// Github: https://github.com/nb312
3 | /// Email: niebin312@gmail.com
4 | ///
5 | class SingleManager {
6 | SingleManager._();
7 |
8 | factory SingleManager() => _getInstance();
9 | static SingleManager _instance;
10 |
11 | static SingleManager get instance => _getInstance();
12 |
13 | static SingleManager _getInstance() {
14 | if (_instance == null) {
15 | _instance = SingleManager._();
16 | }
17 | return _instance;
18 | }
19 |
20 | int count = 0;
21 | }
22 |
--------------------------------------------------------------------------------
/lib/page/single/single_page.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:flutter_design/constant/string_const.dart';
3 | import 'package:flutter_design/page/single/single_manager.dart';
4 |
5 | /// Created by NieBin on 2020-03-17
6 | /// Github: https://github.com/nb312
7 | /// Email: niebin312@gmail.com
8 | class SinglePage extends StatefulWidget {
9 | @override
10 | _SinglePageState createState() => _SinglePageState();
11 | }
12 |
13 | class _SinglePageState extends State {
14 | @override
15 | Widget build(BuildContext context) {
16 | return Scaffold(
17 | appBar: AppBar(
18 | title: Text(StringConst.SINGLE_),
19 | ),
20 | body: Column(
21 | children: [
22 | Expanded(
23 | child: Container(
24 | child: Center(
25 | child: Text(
26 | "${SingleManager.instance.count ?? "没有数据"}",
27 | style: TextStyle(
28 | fontWeight: FontWeight.bold,
29 | fontSize: 50,
30 | color: Colors.red),
31 | ),
32 | ),
33 | ),
34 | ),
35 | Row(
36 | mainAxisAlignment: MainAxisAlignment.center,
37 | children: [
38 | Expanded(
39 | child: FlatButton(
40 | color: Colors.red,
41 | child: Padding(
42 | padding: const EdgeInsets.all(8.0),
43 | child: Icon(
44 | Icons.do_not_disturb_on,
45 | size: 30,
46 | color: Colors.white,
47 | ),
48 | ),
49 | shape: CircleBorder(),
50 | onPressed: () {
51 | setState(() {
52 | SingleManager.instance.count -= 5;
53 | });
54 | },
55 | ),
56 | ),
57 | Expanded(
58 | child: FlatButton(
59 | color: Colors.blue,
60 | child: Padding(
61 | padding: const EdgeInsets.all(8.0),
62 | child: Icon(
63 | Icons.add_circle,
64 | size: 30,
65 | color: Colors.white,
66 | ),
67 | ),
68 | shape: CircleBorder(),
69 | onPressed: () {
70 | setState(() {
71 | SingleManager.instance.count += 5;
72 | });
73 | },
74 | ),
75 | )
76 | ],
77 | ),
78 | SizedBox(
79 | height: 100,
80 | )
81 | ],
82 | ),
83 | );
84 | }
85 | }
86 |
--------------------------------------------------------------------------------
/lib/page/state/state_mode.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/cupertino.dart';
2 |
3 | /// Created by NieBin on 2020-04-14
4 | /// Github: https://github.com/nb312
5 | /// Email: niebin312@gmail.com
6 | ///参考文章https://www.runoob.com/w3cnote/state-vs-strategy.html
7 | abstract class State {
8 | void eatWater();
9 |
10 | void watchSea();
11 | }
12 |
13 | class FlyState extends State {
14 | @override
15 | void eatWater() {
16 | print("高空跳伞太危险不能喝水");
17 | }
18 |
19 | @override
20 | void watchSea() {
21 | print("飞得高看得远,整个大海都尽收眼底");
22 | }
23 | }
24 |
25 | class SubWayState extends State {
26 | @override
27 | void eatWater() {
28 | print("拿起你的矿泉水瓶开始喝水");
29 | }
30 |
31 | @override
32 | void watchSea() {
33 | print("拿起手机开始看大海的视频");
34 | }
35 | }
36 |
37 | class HomeState extends State {
38 | @override
39 | void eatWater() {
40 | print("用杯子倒一杯水喝了起来");
41 | }
42 |
43 | @override
44 | void watchSea() {
45 | print("打卡电视机,调到能看大海的频道");
46 | }
47 | }
48 |
49 | //如果程序员要执行这些状态会怎么样呢
50 | class Programmer extends State {
51 | FlyState _flyState = FlyState();
52 | SubWayState _subWayState = SubWayState();
53 | HomeState _homeState = HomeState();
54 |
55 | State get fly => _flyState;
56 |
57 | State get subway => _subWayState;
58 |
59 | State get homeState => _homeState;
60 | State state;
61 |
62 | Programmer() {
63 | state = homeState;
64 | }
65 |
66 | @override
67 | void eatWater() {
68 | state?.eatWater();
69 | }
70 |
71 | @override
72 | void watchSea() {
73 | state.watchSea();
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/lib/page/state/state_page.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:flutter_design/page/state/state_mode.dart' as s;
3 |
4 | /// Created by NieBin on 2020-04-14
5 | /// Github: https://github.com/nb312
6 | /// Email: niebin312@gmail.com
7 |
8 | class StatePage extends StatefulWidget {
9 | @override
10 | _StatePageState createState() => _StatePageState();
11 | }
12 |
13 | class _StatePageState extends State {
14 | s.Programmer _programmer;
15 |
16 | @override
17 | void initState() {
18 | _programmer = s.Programmer();
19 | super.initState();
20 | }
21 |
22 | @override
23 | Widget build(BuildContext context) {
24 | return Scaffold(
25 | appBar: AppBar(
26 | title: Text("状态模式"),
27 | ),
28 | body: Container(
29 | child: Column(
30 | children: [
31 | FlatButton(
32 | color: Colors.red,
33 | child: Text("跳伞飞起来"),
34 | onPressed: () {
35 | _programmer.state = s.FlyState();
36 | },
37 | ),
38 | FlatButton(
39 | color: Colors.yellow,
40 | child: Text("坐地铁"),
41 | onPressed: () {
42 | _programmer.state = s.SubWayState();
43 | },
44 | ),
45 | FlatButton(
46 | color: Colors.orange,
47 | child: Text("在家里"),
48 | onPressed: () {
49 | _programmer.state = s.HomeState();
50 | },
51 | ),
52 | FlatButton(
53 | color: Colors.green,
54 | child: Text("喝水"),
55 | onPressed: () {
56 | _programmer.eatWater();
57 | },
58 | ),
59 | FlatButton(
60 | color: Colors.pink,
61 | child: Text("看海"),
62 | onPressed: () {
63 | _programmer.watchSea();
64 | },
65 | )
66 | ],
67 | ),
68 | ),
69 | );
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/lib/page/strategy/strategy_mode.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/cupertino.dart';
2 |
3 | /// Created by NieBin on 2020-04-15
4 | /// Github: https://github.com/nb312
5 | /// Email: niebin312@gmail.com
6 | abstract class IMove {
7 | void run();
8 | }
9 |
10 | class Fly extends IMove {
11 | @override
12 | void run() {
13 | debugPrint("我用飞的不香吗");
14 | }
15 | }
16 |
17 | //
18 | class Run extends IMove {
19 | @override
20 | void run() {
21 | debugPrint("跑步使我快乐");
22 | }
23 | }
24 |
25 | class Walk extends IMove {
26 | @override
27 | void run() {
28 | debugPrint("散散步也不无不行");
29 | }
30 | }
31 |
32 | class ByBike extends IMove {
33 | @override
34 | void run() {
35 | debugPrint("骑行也是很环保的");
36 | }
37 | }
38 |
39 | class ByBus extends IMove {
40 | @override
41 | void run() {
42 | debugPrint("还是老司机开车快点");
43 | }
44 | }
45 |
46 | class Context implements IMove {
47 | IMove move;
48 |
49 | @override
50 | void run() {
51 | move?.run();
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/lib/page/strategy/strategy_page.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/foundation.dart';
2 | import 'package:flutter/material.dart';
3 | import 'package:flutter_design/page/strategy/strategy_mode.dart';
4 |
5 | /// Created by NieBin on 2020-04-15
6 | /// Github: https://github.com/nb312
7 | /// Email: niebin312@gmail.com
8 |
9 | class StrategyPage extends StatefulWidget {
10 | @override
11 | _StrategyPageState createState() => _StrategyPageState();
12 | }
13 |
14 | class _StrategyPageState extends State {
15 | Context _context;
16 |
17 | @override
18 | void initState() {
19 | _context = Context();
20 | super.initState();
21 | }
22 |
23 | @override
24 | Widget build(BuildContext context) {
25 | return Scaffold(
26 | appBar: AppBar(
27 | title: Text("策略模式"),
28 | ),
29 | body: Container(
30 | constraints: BoxConstraints.expand(),
31 | child: Column(
32 | crossAxisAlignment: CrossAxisAlignment.center,
33 | children: [
34 | FlatButton(
35 | color: Colors.red,
36 | child: Padding(
37 | padding: const EdgeInsets.all(8.0),
38 | child: Text("开始飞"),
39 | ),
40 | onPressed: () {
41 | _context.move = Fly();
42 | _context.run();
43 | },
44 | ),
45 | FlatButton(
46 | color: Colors.green,
47 | child: Padding(
48 | padding: const EdgeInsets.all(8.0),
49 | child: Text("开始跑"),
50 | ),
51 | onPressed: () {
52 | _context.move = Run();
53 | _context.run();
54 | },
55 | ),
56 | FlatButton(
57 | color: Colors.yellow,
58 | child: Padding(
59 | padding: const EdgeInsets.all(8.0),
60 | child: Text("开始散步"),
61 | ),
62 | onPressed: () {
63 | _context.move = Walk();
64 | _context.run();
65 | },
66 | ),
67 | FlatButton(
68 | color: Colors.blue,
69 | child: Padding(
70 | padding: const EdgeInsets.all(8.0),
71 | child: Text("开始骑行"),
72 | ),
73 | onPressed: () {
74 | _context.move = ByBike();
75 | _context.run();
76 | },
77 | ),
78 | FlatButton(
79 | color: Colors.orange,
80 | child: Padding(
81 | padding: const EdgeInsets.all(8.0),
82 | child: Text("开始开车"),
83 | ),
84 | onPressed: () {
85 | _context.move = ByBus();
86 | _context.run();
87 | print("${Container(
88 | child: Text("Hello world"),
89 | ).toStringDeep()}");
90 | ObserverList list = ObserverList();
91 | list.add("Hello world");
92 | },
93 | ),
94 | ],
95 | ),
96 | ),
97 | );
98 | }
99 | }
100 |
--------------------------------------------------------------------------------
/lib/page/template/template_mode.dart:
--------------------------------------------------------------------------------
1 | /// Created by NieBin on 2020-04-16
2 | /// Github: https://github.com/nb312
3 | /// Email: niebin312@gmail.com
4 | abstract class IWork {
5 | void start();
6 |
7 | void working();
8 |
9 | void end();
10 |
11 | void work() {
12 | start();
13 | working();
14 | end();
15 | }
16 | }
17 |
18 | class NieBin extends IWork {
19 | @override
20 | void end() {
21 | print("加班后下班");
22 | }
23 |
24 | @override
25 | void start() {
26 | print("从上海地铁站上站");
27 | }
28 |
29 | @override
30 | void working() {
31 | print("进行Flutter开发");
32 | }
33 | }
34 |
35 | class Other extends IWork {
36 | @override
37 | void end() {
38 | print("开开心心下班");
39 | }
40 |
41 | @override
42 | void start() {
43 | print("从公司附近出发");
44 | }
45 |
46 | @override
47 | void working() {
48 | print("进行前端开发");
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/lib/page/template/template_page.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:flutter_design/page/template/template_mode.dart';
3 |
4 | /// Created by NieBin on 2020-04-16
5 | /// Github: https://github.com/nb312
6 | /// Email: niebin312@gmail.com
7 |
8 | class TemplatePage extends StatefulWidget {
9 | @override
10 | _TemplatePageState createState() => _TemplatePageState();
11 | }
12 |
13 | class _TemplatePageState extends State {
14 | @override
15 | Widget build(BuildContext context) {
16 | return Scaffold(
17 | appBar: AppBar(
18 | title: Text("模版模式"),
19 | ),
20 | body: Container(
21 | child: Column(
22 | children: [
23 | FlatButton(
24 | color: Colors.orange,
25 | child: Padding(
26 | padding: const EdgeInsets.all(8.0),
27 | child: Text("NieBin的工作日常"),
28 | ),
29 | onPressed: () {
30 | NieBin nb = NieBin();
31 | nb.work();
32 | },
33 | ),
34 | FlatButton(
35 | color: Colors.orange,
36 | child: Padding(
37 | padding: const EdgeInsets.all(8.0),
38 | child: Text("其他人的工作日常"),
39 | ),
40 | onPressed: () {
41 | Other other = Other();
42 | other.work();
43 | },
44 | ),
45 | ],
46 | ),
47 | ),
48 | );
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/pubspec.lock:
--------------------------------------------------------------------------------
1 | # Generated by pub
2 | # See https://dart.dev/tools/pub/glossary#lockfile
3 | packages:
4 | archive:
5 | dependency: transitive
6 | description:
7 | name: archive
8 | url: "https://pub.dartlang.org"
9 | source: hosted
10 | version: "2.0.11"
11 | args:
12 | dependency: transitive
13 | description:
14 | name: args
15 | url: "https://pub.dartlang.org"
16 | source: hosted
17 | version: "1.5.2"
18 | async:
19 | dependency: transitive
20 | description:
21 | name: async
22 | url: "https://pub.dartlang.org"
23 | source: hosted
24 | version: "2.4.0"
25 | boolean_selector:
26 | dependency: transitive
27 | description:
28 | name: boolean_selector
29 | url: "https://pub.dartlang.org"
30 | source: hosted
31 | version: "1.0.5"
32 | charcode:
33 | dependency: transitive
34 | description:
35 | name: charcode
36 | url: "https://pub.dartlang.org"
37 | source: hosted
38 | version: "1.1.2"
39 | collection:
40 | dependency: transitive
41 | description:
42 | name: collection
43 | url: "https://pub.dartlang.org"
44 | source: hosted
45 | version: "1.14.11"
46 | convert:
47 | dependency: transitive
48 | description:
49 | name: convert
50 | url: "https://pub.dartlang.org"
51 | source: hosted
52 | version: "2.1.1"
53 | crypto:
54 | dependency: transitive
55 | description:
56 | name: crypto
57 | url: "https://pub.dartlang.org"
58 | source: hosted
59 | version: "2.1.3"
60 | cupertino_icons:
61 | dependency: "direct main"
62 | description:
63 | name: cupertino_icons
64 | url: "https://pub.dartlang.org"
65 | source: hosted
66 | version: "0.1.3"
67 | flutter:
68 | dependency: "direct main"
69 | description: flutter
70 | source: sdk
71 | version: "0.0.0"
72 | flutter_test:
73 | dependency: "direct dev"
74 | description: flutter
75 | source: sdk
76 | version: "0.0.0"
77 | image:
78 | dependency: transitive
79 | description:
80 | name: image
81 | url: "https://pub.dartlang.org"
82 | source: hosted
83 | version: "2.1.4"
84 | matcher:
85 | dependency: transitive
86 | description:
87 | name: matcher
88 | url: "https://pub.dartlang.org"
89 | source: hosted
90 | version: "0.12.6"
91 | meta:
92 | dependency: transitive
93 | description:
94 | name: meta
95 | url: "https://pub.dartlang.org"
96 | source: hosted
97 | version: "1.1.8"
98 | path:
99 | dependency: transitive
100 | description:
101 | name: path
102 | url: "https://pub.dartlang.org"
103 | source: hosted
104 | version: "1.6.4"
105 | pedantic:
106 | dependency: transitive
107 | description:
108 | name: pedantic
109 | url: "https://pub.dartlang.org"
110 | source: hosted
111 | version: "1.8.0+1"
112 | petitparser:
113 | dependency: transitive
114 | description:
115 | name: petitparser
116 | url: "https://pub.dartlang.org"
117 | source: hosted
118 | version: "2.4.0"
119 | quiver:
120 | dependency: transitive
121 | description:
122 | name: quiver
123 | url: "https://pub.dartlang.org"
124 | source: hosted
125 | version: "2.0.5"
126 | sky_engine:
127 | dependency: transitive
128 | description: flutter
129 | source: sdk
130 | version: "0.0.99"
131 | source_span:
132 | dependency: transitive
133 | description:
134 | name: source_span
135 | url: "https://pub.dartlang.org"
136 | source: hosted
137 | version: "1.5.5"
138 | stack_trace:
139 | dependency: transitive
140 | description:
141 | name: stack_trace
142 | url: "https://pub.dartlang.org"
143 | source: hosted
144 | version: "1.9.3"
145 | stream_channel:
146 | dependency: transitive
147 | description:
148 | name: stream_channel
149 | url: "https://pub.dartlang.org"
150 | source: hosted
151 | version: "2.0.0"
152 | string_scanner:
153 | dependency: transitive
154 | description:
155 | name: string_scanner
156 | url: "https://pub.dartlang.org"
157 | source: hosted
158 | version: "1.0.5"
159 | term_glyph:
160 | dependency: transitive
161 | description:
162 | name: term_glyph
163 | url: "https://pub.dartlang.org"
164 | source: hosted
165 | version: "1.1.0"
166 | test_api:
167 | dependency: transitive
168 | description:
169 | name: test_api
170 | url: "https://pub.dartlang.org"
171 | source: hosted
172 | version: "0.2.11"
173 | typed_data:
174 | dependency: transitive
175 | description:
176 | name: typed_data
177 | url: "https://pub.dartlang.org"
178 | source: hosted
179 | version: "1.1.6"
180 | vector_math:
181 | dependency: transitive
182 | description:
183 | name: vector_math
184 | url: "https://pub.dartlang.org"
185 | source: hosted
186 | version: "2.0.8"
187 | xml:
188 | dependency: transitive
189 | description:
190 | name: xml
191 | url: "https://pub.dartlang.org"
192 | source: hosted
193 | version: "3.5.0"
194 | sdks:
195 | dart: ">=2.4.0 <3.0.0"
196 |
--------------------------------------------------------------------------------
/pubspec.yaml:
--------------------------------------------------------------------------------
1 | name: flutter_design
2 | description: A new Flutter application.
3 |
4 | # The following defines the version and build number for your application.
5 | # A version number is three numbers separated by dots, like 1.2.43
6 | # followed by an optional build number separated by a +.
7 | # Both the version and the builder number may be overridden in flutter
8 | # build by specifying --build-name and --build-number, respectively.
9 | # In Android, build-name is used as versionName while build-number used as versionCode.
10 | # Read more about Android versioning at https://developer.android.com/studio/publish/versioning
11 | # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
12 | # Read more about iOS versioning at
13 | # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
14 | version: 1.0.0+1
15 |
16 | environment:
17 | sdk: ">=2.1.0 <3.0.0"
18 |
19 | dependencies:
20 | flutter:
21 | sdk: flutter
22 |
23 | # The following adds the Cupertino Icons font to your application.
24 | # Use with the CupertinoIcons class for iOS style icons.
25 | cupertino_icons: ^0.1.2
26 |
27 | dev_dependencies:
28 | flutter_test:
29 | sdk: flutter
30 |
31 |
32 | # For information on the generic Dart part of this file, see the
33 | # following page: https://dart.dev/tools/pub/pubspec
34 |
35 | # The following section is specific to Flutter.
36 | flutter:
37 |
38 | # The following line ensures that the Material Icons font is
39 | # included with your application, so that you can use the icons in
40 | # the material Icons class.
41 | uses-material-design: true
42 |
43 | # To add assets to your application, add an assets section, like this:
44 | # assets:
45 | # - images/a_dot_burr.jpeg
46 | # - images/a_dot_ham.jpeg
47 |
48 | # An image asset can refer to one or more resolution-specific "variants", see
49 | # https://flutter.dev/assets-and-images/#resolution-aware.
50 |
51 | # For details regarding adding assets from package dependencies, see
52 | # https://flutter.dev/assets-and-images/#from-packages
53 |
54 | # To add custom fonts to your application, add a fonts section here,
55 | # in this "flutter" section. Each entry in this list should have a
56 | # "family" key with the font family name, and a "fonts" key with a
57 | # list giving the asset and other descriptors for the font. For
58 | # example:
59 | # fonts:
60 | # - family: Schyler
61 | # fonts:
62 | # - asset: fonts/Schyler-Regular.ttf
63 | # - asset: fonts/Schyler-Italic.ttf
64 | # style: italic
65 | # - family: Trajan Pro
66 | # fonts:
67 | # - asset: fonts/TrajanPro.ttf
68 | # - asset: fonts/TrajanPro_Bold.ttf
69 | # weight: 700
70 | #
71 | # For details regarding fonts from package dependencies,
72 | # see https://flutter.dev/custom-fonts/#from-packages
73 |
--------------------------------------------------------------------------------
/test/widget_test.dart:
--------------------------------------------------------------------------------
1 | // This is a basic Flutter widget test.
2 | //
3 | // To perform an interaction with a widget in your test, use the WidgetTester
4 | // utility that Flutter provides. For example, you can send tap and scroll
5 | // gestures. You can also use WidgetTester to find child widgets in the widget
6 | // tree, read text, and verify that the values of widget properties are correct.
7 |
8 | import 'package:flutter/material.dart';
9 | import 'package:flutter_test/flutter_test.dart';
10 |
11 | import 'package:flutter_design/main.dart';
12 |
13 | void main() {
14 | testWidgets('Counter increments smoke test', (WidgetTester tester) async {
15 | // Build our app and trigger a frame.
16 | await tester.pumpWidget(MyApp());
17 |
18 | // Verify that our counter starts at 0.
19 | expect(find.text('0'), findsOneWidget);
20 | expect(find.text('1'), findsNothing);
21 |
22 | // Tap the '+' icon and trigger a frame.
23 | await tester.tap(find.byIcon(Icons.add));
24 | await tester.pump();
25 |
26 | // Verify that our counter has incremented.
27 | expect(find.text('0'), findsNothing);
28 | expect(find.text('1'), findsOneWidget);
29 | });
30 | }
31 |
--------------------------------------------------------------------------------
/web/icons/Icon-192.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FlutterOpen/design_patterns/93b7059718ac42d9d772205eaf697f81fb8aef07/web/icons/Icon-192.png
--------------------------------------------------------------------------------
/web/icons/Icon-512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FlutterOpen/design_patterns/93b7059718ac42d9d772205eaf697f81fb8aef07/web/icons/Icon-512.png
--------------------------------------------------------------------------------
/web/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 | flutter_design
15 |
16 |
17 |
18 |
21 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/web/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "flutter_design",
3 | "short_name": "flutter_design",
4 | "start_url": ".",
5 | "display": "minimal-ui",
6 | "background_color": "#0175C2",
7 | "theme_color": "#0175C2",
8 | "description": "A new Flutter application.",
9 | "orientation": "portrait-primary",
10 | "prefer_related_applications": false,
11 | "icons": [
12 | {
13 | "src": "icons/Icon-192.png",
14 | "sizes": "192x192",
15 | "type": "image/png"
16 | },
17 | {
18 | "src": "icons/Icon-512.png",
19 | "sizes": "512x512",
20 | "type": "image/png"
21 | }
22 | ]
23 | }
24 |
--------------------------------------------------------------------------------