├── .gitignore ├── .metadata ├── LICENSE ├── README.md ├── android ├── .gitignore ├── app │ ├── build.gradle │ └── src │ │ ├── debug │ │ └── AndroidManifest.xml │ │ ├── main │ │ ├── AndroidManifest.xml │ │ ├── kotlin │ │ │ └── com │ │ │ │ └── example │ │ │ │ └── flutter_template_plus │ │ │ │ └── MainActivity.kt │ │ └── res │ │ │ ├── drawable-v21 │ │ │ └── launch_background.xml │ │ │ ├── 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-night │ │ │ └── styles.xml │ │ │ └── values │ │ │ └── styles.xml │ │ └── profile │ │ └── AndroidManifest.xml ├── build.gradle ├── gradle.properties ├── gradle │ └── wrapper │ │ └── gradle-wrapper.properties └── settings.gradle ├── assets ├── icons │ └── iconfont.ttf ├── images │ ├── docs │ │ ├── login_dark.jpg │ │ └── login_light.jpg │ └── login │ │ ├── logo.png │ │ └── unpany.png └── jsons │ └── demo.json ├── ios ├── .gitignore ├── Flutter │ ├── AppFrameworkInfo.plist │ ├── Debug.xcconfig │ └── Release.xcconfig ├── Runner.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ ├── IDEWorkspaceChecks.plist │ │ │ └── WorkspaceSettings.xcsettings │ └── xcshareddata │ │ └── xcschemes │ │ └── Runner.xcscheme ├── Runner.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ ├── IDEWorkspaceChecks.plist │ │ └── WorkspaceSettings.xcsettings └── 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 ├── common │ ├── my_color.dart │ ├── my_constants.dart │ ├── my_init.dart │ └── my_state.dart ├── db │ └── my_cache.dart ├── http │ ├── adapter │ │ ├── dio_adapter.dart │ │ └── mock_adapter.dart │ ├── core │ │ ├── my_base_request.dart │ │ ├── my_net.dart │ │ ├── my_net_adapter.dart │ │ └── my_net_error.dart │ ├── dao │ │ └── login_dao.dart │ └── request │ │ └── login_request.dart ├── main.dart ├── models │ └── demo_model.dart ├── navigator │ ├── my_navigator.dart │ ├── my_navigator_util.dart │ └── my_router_delegate.dart ├── pages │ ├── detail_page.dart │ ├── home_page.dart │ ├── login_page.dart │ ├── me_page.dart │ └── navigator_page.dart ├── provider │ ├── my_provider.dart │ └── theme_provider.dart ├── utils │ ├── device_util.dart │ └── string_util.dart └── widgets │ └── login_input.dart ├── pubspec.lock └── pubspec.yaml /.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 | **/ios/Flutter/.last_build_id 26 | .dart_tool/ 27 | .flutter-plugins 28 | .flutter-plugins-dependencies 29 | .packages 30 | .pub-cache/ 31 | .pub/ 32 | /build/ 33 | 34 | # Web related 35 | lib/generated_plugin_registrant.dart 36 | 37 | # Symbolication related 38 | app.*.symbols 39 | 40 | # Obfuscation related 41 | app.*.map.json 42 | 43 | # Android Studio will place build artifacts here 44 | /android/app/debug 45 | /android/app/profile 46 | /android/app/release 47 | -------------------------------------------------------------------------------- /.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: 18116933e77adc82f80866c928266a5b4f1ed645 8 | channel: stable 9 | 10 | project_type: app 11 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 UNPany 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## 简介 2 | 3 | 一个 APP 项目通用模板,提供 HTTP、路由、本地缓存等常用功能的一方库 4 | 5 | ## 效果图 6 | 7 | ![login_light.jpg](assets/images/docs/login_light.jpg) 8 | ![login_dark.jpg](assets/images/docs/login_dark.jpg) 9 | 10 | ## 功能 11 | 12 | ```text 13 | - 身份认证 14 | - 登录 15 | - 登出 16 | 17 | - HTTP 18 | - 基于三方库 Dio 封装一方库 MyNet 19 | - 响应拦截 20 | 21 | - 路由 22 | - 封装 Navigator 2.0 23 | - 路由拦截 24 | 25 | - 状态管理 26 | - 基于三方库 provider 27 | - 黑暗模式 28 | 29 | - 本地缓存 30 | - 基于三方库 shared_preferences 封装一方库 MyCache 31 | 32 | - 其他 33 | - 项目预初始化 34 | - 两次返回确认 35 | ``` 36 | 37 | ## 目录结构 38 | 39 | ``` 40 | # flutter_template_plus 41 | ├─ assets # 静态资源 42 | │ ├─ icons # 字体图标 43 | │ ├─ images # 图片 44 | │ ├─ jsons # json 文件 45 | ├─ lib 46 | │ ├─ common # 全局公共类、方法、变量等 47 | │ ├─ db # 本地缓存 48 | │ ├─ http # http 层 49 | │ │ ├─ adapter # 适配器 50 | │ │ ├─ core # 一方库 51 | │ │ ├─ dao # 数据访问层 52 | │ │ └─ request # 请求 53 | │ ├─ models # model 层 54 | │ ├─ navigator # Navigator 2.0 55 | │ ├─ pages # 所有页面 56 | │ ├─ provider # 状态管理 57 | │ ├─ utils # 工具类 58 | ├─ └─ main.dart # 入口 59 | └─ pubspec.yaml # 包管理 60 | ``` 61 | 62 | ## 开发 63 | 64 | ```bash 65 | # 安装依赖 66 | flutter packages get 或 flutter pub get 67 | 68 | # 分析代码 69 | flutter analyze 70 | 71 | # 运行项目 72 | flutter run 73 | 74 | # 如果遇到着色器渲染错误(Shader compilation error),可以运行 clean 后再 run 75 | flutter clean 76 | 77 | # 安卓真机调试 78 | flutter devices 79 | flutter run 80 | 81 | # 安卓打包 82 | flutter build apk 83 | ``` 84 | 85 | ## 开发环境 86 | 87 | 1. Flutter version 2.8.0 88 | 2. Dart version 2.15.0 89 | 3. Android SDK version 31.0.0 90 | 91 | ## 开发工具 92 | 93 | 1. 编辑器 Visual Studio Code 94 | 2. 插件 Dart 95 | 3. 插件 Flutter 96 | 4. 插件 Flutter Widget Snippets 97 | 98 | ## Git 提交规范 99 | 100 | - `feat` 增加新功能 101 | - `fix` 修复问题/BUG 102 | - `style` 代码风格相关无影响运行结果的 103 | - `perf` 优化/性能提升 104 | - `refactor` 重构 105 | - `revert` 撤销修改 106 | - `test` 测试相关 107 | - `docs` 文档/注释 108 | - `chore` 依赖更新/脚手架配置修改等 109 | - `workflow` 工作流改进 110 | - `ci` 持续集成 111 | - `types` 类型定义文件更改 112 | - `wip` 开发中 113 | - `mod` 不确定分类的修改 114 | 115 | ## ❓ 关于 JSON 转 Dart Model 类 116 | 117 | 1. 纯手写实体类(不推荐) 118 | 2. **用网页自动生成工具: 根据 JSON 自动生成实体类,并 copy 到项目中(所有项目都通用)** 119 | 3. 使用插件 json_serializable(更适合大型项目) 120 | 121 | **该脚手架采用第二种方案** 122 | 123 | 这里随便提供一个自动生成的网址:[json_to_dart](https://javiercbk.github.io/json_to_dart/) 124 | 125 | *JSON <——> Map <——> Dart Model 三者之间的转化是常用的技巧* 126 | 127 | ## ❓ 关于路由 128 | 129 | 1. 官方的 Navigator 1.0 130 | 2. **官方的 Navigator 2.0 (Flutter 1.22 推出)** 131 | 3. 三方插件 fluro 132 | 133 | **该脚手架采用第二种方案,并对其封装** 134 | 135 | *Navigator 2.0 的概念有一定的难度* 136 | 137 | ## ❓ 关于 flutter_template_plus 和 flutter_template_mini 和 flutter-bruno-getx 138 | 139 | 1. mini 版的路由采用 Navigator 1.0,逻辑简单易懂,而 plus 版则采用更加强大,但难以理解的 Navigator 2.0 140 | 2. mini 版的 HTTP 层直接基于 Dio 进行封装,代码结构清晰简单,而 plus 版则书写一方库 MyNet,通过适配器集成 Dio,更加灵活、可插拔 141 | 3. mini 版的 db 层直接基于 shared_preferences 进行封装,而 plus 版则基于 shared_preferences 书写一方库 MyCache 142 | 4. mini 版的封装方式更贴近现代**前端工程**,而 plus 版则更加**面向对象** 143 | 5. flutter-bruno-getx 则完全基于 mini 版,并采用了最新的 SDK、Bruno UI 框架、GetX 状态管理器 144 | 145 | ## 不同版本 146 | 147 | 1. [flutter_template_plus](https://github.com/un-pany/flutter-template-plus) 148 | 2. [flutter_template_mini](https://github.com/un-pany/flutter-template-mini) 149 | 3. [flutter-bruno-getx](https://github.com/un-pany/flutter-bruno-getx) 150 | 151 | ## 📚 入门 Flutter 系列文章 152 | 153 | 1. [Flutter 从 0 到 1](https://juejin.cn/column/6995160230476644366) 154 | 2. [移动端学习小记](https://juejin.cn/column/6991310785871872007) 155 | 156 | ## 📄 License 157 | 158 | [MIT](https://github.com/un-pany/flutter-template-plus/blob/main/LICENSE) 159 | 160 | Copyright (c) 2021 UNPany 161 | -------------------------------------------------------------------------------- /android/.gitignore: -------------------------------------------------------------------------------- 1 | gradle-wrapper.jar 2 | /.gradle 3 | /captures/ 4 | /gradlew 5 | /gradlew.bat 6 | /local.properties 7 | GeneratedPluginRegistrant.java 8 | 9 | # Remember to never publicly share your keystore. 10 | # See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app 11 | key.properties 12 | **/*.keystore 13 | **/*.jks 14 | -------------------------------------------------------------------------------- /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 31 30 | 31 | compileOptions { 32 | sourceCompatibility JavaVersion.VERSION_1_8 33 | targetCompatibility JavaVersion.VERSION_1_8 34 | } 35 | 36 | kotlinOptions { 37 | jvmTarget = '1.8' 38 | } 39 | 40 | sourceSets { 41 | main.java.srcDirs += 'src/main/kotlin' 42 | } 43 | 44 | defaultConfig { 45 | // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). 46 | applicationId "com.example.flutter_template_plus" 47 | minSdkVersion 22 48 | targetSdkVersion 31 49 | versionCode flutterVersionCode.toInteger() 50 | versionName flutterVersionName 51 | } 52 | 53 | buildTypes { 54 | release { 55 | // TODO: Add your own signing config for the release build. 56 | // Signing with the debug keys for now, so `flutter run --release` works. 57 | signingConfig signingConfigs.debug 58 | } 59 | } 60 | } 61 | 62 | flutter { 63 | source '../..' 64 | } 65 | 66 | dependencies { 67 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" 68 | } 69 | -------------------------------------------------------------------------------- /android/app/src/debug/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 6 | 14 | 18 | 22 | 27 | 31 | 32 | 33 | 34 | 35 | 36 | 38 | 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /android/app/src/main/kotlin/com/example/flutter_template_plus/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.example.flutter_template_plus 2 | 3 | import io.flutter.embedding.android.FlutterActivity 4 | 5 | class MainActivity: FlutterActivity() { 6 | } 7 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable-v21/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 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/un-pany/flutter-template-plus/381b884e58ffd7f6ebfb884fe8d46e4d4f6fb853/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/un-pany/flutter-template-plus/381b884e58ffd7f6ebfb884fe8d46e4d4f6fb853/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/un-pany/flutter-template-plus/381b884e58ffd7f6ebfb884fe8d46e4d4f6fb853/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/un-pany/flutter-template-plus/381b884e58ffd7f6ebfb884fe8d46e4d4f6fb853/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/un-pany/flutter-template-plus/381b884e58ffd7f6ebfb884fe8d46e4d4f6fb853/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/values-night/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 15 | 18 | 19 | -------------------------------------------------------------------------------- /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 | mavenCentral() 6 | } 7 | 8 | dependencies { 9 | classpath 'com.android.tools.build:gradle:4.1.0' 10 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 11 | } 12 | } 13 | 14 | allprojects { 15 | repositories { 16 | google() 17 | mavenCentral() 18 | } 19 | } 20 | 21 | rootProject.buildDir = '../build' 22 | subprojects { 23 | project.buildDir = "${rootProject.buildDir}/${project.name}" 24 | project.evaluationDependsOn(':app') 25 | } 26 | 27 | task clean(type: Delete) { 28 | delete rootProject.buildDir 29 | } 30 | -------------------------------------------------------------------------------- /android/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx1536M 2 | android.useAndroidX=true 3 | android.enableJetifier=true 4 | -------------------------------------------------------------------------------- /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-6.7-all.zip 7 | -------------------------------------------------------------------------------- /android/settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | 3 | def localPropertiesFile = new File(rootProject.projectDir, "local.properties") 4 | def properties = new Properties() 5 | 6 | assert localPropertiesFile.exists() 7 | localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) } 8 | 9 | def flutterSdkPath = properties.getProperty("flutter.sdk") 10 | assert flutterSdkPath != null, "flutter.sdk not set in local.properties" 11 | apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle" 12 | -------------------------------------------------------------------------------- /assets/icons/iconfont.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/un-pany/flutter-template-plus/381b884e58ffd7f6ebfb884fe8d46e4d4f6fb853/assets/icons/iconfont.ttf -------------------------------------------------------------------------------- /assets/images/docs/login_dark.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/un-pany/flutter-template-plus/381b884e58ffd7f6ebfb884fe8d46e4d4f6fb853/assets/images/docs/login_dark.jpg -------------------------------------------------------------------------------- /assets/images/docs/login_light.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/un-pany/flutter-template-plus/381b884e58ffd7f6ebfb884fe8d46e4d4f6fb853/assets/images/docs/login_light.jpg -------------------------------------------------------------------------------- /assets/images/login/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/un-pany/flutter-template-plus/381b884e58ffd7f6ebfb884fe8d46e4d4f6fb853/assets/images/login/logo.png -------------------------------------------------------------------------------- /assets/images/login/unpany.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/un-pany/flutter-template-plus/381b884e58ffd7f6ebfb884fe8d46e4d4f6fb853/assets/images/login/unpany.png -------------------------------------------------------------------------------- /assets/jsons/demo.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "pany", 3 | "mail": "939630029@qq.com" 4 | } -------------------------------------------------------------------------------- /ios/.gitignore: -------------------------------------------------------------------------------- 1 | **/dgph 2 | *.mode1v3 3 | *.mode2v3 4 | *.moved-aside 5 | *.pbxuser 6 | *.perspectivev3 7 | **/*sync/ 8 | .sconsign.dblite 9 | .tags* 10 | **/.vagrant/ 11 | **/DerivedData/ 12 | Icon? 13 | **/Pods/ 14 | **/.symlinks/ 15 | profile 16 | xcuserdata 17 | **/.generated/ 18 | Flutter/App.framework 19 | Flutter/Flutter.framework 20 | Flutter/Flutter.podspec 21 | Flutter/Generated.xcconfig 22 | Flutter/ephemeral/ 23 | Flutter/app.flx 24 | Flutter/app.zip 25 | Flutter/flutter_assets/ 26 | Flutter/flutter_export_environment.sh 27 | ServiceDefinitions.json 28 | Runner/GeneratedPluginRegistrant.* 29 | 30 | # Exceptions to above rules. 31 | !default.mode1v3 32 | !default.mode2v3 33 | !default.pbxuser 34 | !default.perspectivev3 35 | -------------------------------------------------------------------------------- /ios/Flutter/AppFrameworkInfo.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 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 | 9.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 | 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; }; 13 | 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; }; 14 | 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; }; 15 | 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; }; 16 | /* End PBXBuildFile section */ 17 | 18 | /* Begin PBXCopyFilesBuildPhase section */ 19 | 9705A1C41CF9048500538489 /* Embed Frameworks */ = { 20 | isa = PBXCopyFilesBuildPhase; 21 | buildActionMask = 2147483647; 22 | dstPath = ""; 23 | dstSubfolderSpec = 10; 24 | files = ( 25 | ); 26 | name = "Embed Frameworks"; 27 | runOnlyForDeploymentPostprocessing = 0; 28 | }; 29 | /* End PBXCopyFilesBuildPhase section */ 30 | 31 | /* Begin PBXFileReference section */ 32 | 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; }; 33 | 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; }; 34 | 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; 35 | 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = ""; }; 36 | 74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 37 | 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; }; 38 | 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = ""; }; 39 | 9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = ""; }; 40 | 97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; }; 41 | 97C146FB1CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 42 | 97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 43 | 97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 44 | 97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 45 | /* End PBXFileReference section */ 46 | 47 | /* Begin PBXFrameworksBuildPhase section */ 48 | 97C146EB1CF9000F007C117D /* Frameworks */ = { 49 | isa = PBXFrameworksBuildPhase; 50 | buildActionMask = 2147483647; 51 | files = ( 52 | ); 53 | runOnlyForDeploymentPostprocessing = 0; 54 | }; 55 | /* End PBXFrameworksBuildPhase section */ 56 | 57 | /* Begin PBXGroup section */ 58 | 9740EEB11CF90186004384FC /* Flutter */ = { 59 | isa = PBXGroup; 60 | children = ( 61 | 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */, 62 | 9740EEB21CF90195004384FC /* Debug.xcconfig */, 63 | 7AFA3C8E1D35360C0083082E /* Release.xcconfig */, 64 | 9740EEB31CF90195004384FC /* Generated.xcconfig */, 65 | ); 66 | name = Flutter; 67 | sourceTree = ""; 68 | }; 69 | 97C146E51CF9000F007C117D = { 70 | isa = PBXGroup; 71 | children = ( 72 | 9740EEB11CF90186004384FC /* Flutter */, 73 | 97C146F01CF9000F007C117D /* Runner */, 74 | 97C146EF1CF9000F007C117D /* Products */, 75 | ); 76 | sourceTree = ""; 77 | }; 78 | 97C146EF1CF9000F007C117D /* Products */ = { 79 | isa = PBXGroup; 80 | children = ( 81 | 97C146EE1CF9000F007C117D /* Runner.app */, 82 | ); 83 | name = Products; 84 | sourceTree = ""; 85 | }; 86 | 97C146F01CF9000F007C117D /* Runner */ = { 87 | isa = PBXGroup; 88 | children = ( 89 | 97C146FA1CF9000F007C117D /* Main.storyboard */, 90 | 97C146FD1CF9000F007C117D /* Assets.xcassets */, 91 | 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */, 92 | 97C147021CF9000F007C117D /* Info.plist */, 93 | 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */, 94 | 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */, 95 | 74858FAE1ED2DC5600515810 /* AppDelegate.swift */, 96 | 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */, 97 | ); 98 | path = Runner; 99 | sourceTree = ""; 100 | }; 101 | /* End PBXGroup section */ 102 | 103 | /* Begin PBXNativeTarget section */ 104 | 97C146ED1CF9000F007C117D /* Runner */ = { 105 | isa = PBXNativeTarget; 106 | buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */; 107 | buildPhases = ( 108 | 9740EEB61CF901F6004384FC /* Run Script */, 109 | 97C146EA1CF9000F007C117D /* Sources */, 110 | 97C146EB1CF9000F007C117D /* Frameworks */, 111 | 97C146EC1CF9000F007C117D /* Resources */, 112 | 9705A1C41CF9048500538489 /* Embed Frameworks */, 113 | 3B06AD1E1E4923F5004D2608 /* Thin Binary */, 114 | ); 115 | buildRules = ( 116 | ); 117 | dependencies = ( 118 | ); 119 | name = Runner; 120 | productName = Runner; 121 | productReference = 97C146EE1CF9000F007C117D /* Runner.app */; 122 | productType = "com.apple.product-type.application"; 123 | }; 124 | /* End PBXNativeTarget section */ 125 | 126 | /* Begin PBXProject section */ 127 | 97C146E61CF9000F007C117D /* Project object */ = { 128 | isa = PBXProject; 129 | attributes = { 130 | LastUpgradeCheck = 1020; 131 | ORGANIZATIONNAME = ""; 132 | TargetAttributes = { 133 | 97C146ED1CF9000F007C117D = { 134 | CreatedOnToolsVersion = 7.3.1; 135 | LastSwiftMigration = 1100; 136 | }; 137 | }; 138 | }; 139 | buildConfigurationList = 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */; 140 | compatibilityVersion = "Xcode 9.3"; 141 | developmentRegion = en; 142 | hasScannedForEncodings = 0; 143 | knownRegions = ( 144 | en, 145 | Base, 146 | ); 147 | mainGroup = 97C146E51CF9000F007C117D; 148 | productRefGroup = 97C146EF1CF9000F007C117D /* Products */; 149 | projectDirPath = ""; 150 | projectRoot = ""; 151 | targets = ( 152 | 97C146ED1CF9000F007C117D /* Runner */, 153 | ); 154 | }; 155 | /* End PBXProject section */ 156 | 157 | /* Begin PBXResourcesBuildPhase section */ 158 | 97C146EC1CF9000F007C117D /* Resources */ = { 159 | isa = PBXResourcesBuildPhase; 160 | buildActionMask = 2147483647; 161 | files = ( 162 | 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */, 163 | 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */, 164 | 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */, 165 | 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */, 166 | ); 167 | runOnlyForDeploymentPostprocessing = 0; 168 | }; 169 | /* End PBXResourcesBuildPhase section */ 170 | 171 | /* Begin PBXShellScriptBuildPhase section */ 172 | 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = { 173 | isa = PBXShellScriptBuildPhase; 174 | buildActionMask = 2147483647; 175 | files = ( 176 | ); 177 | inputPaths = ( 178 | ); 179 | name = "Thin Binary"; 180 | outputPaths = ( 181 | ); 182 | runOnlyForDeploymentPostprocessing = 0; 183 | shellPath = /bin/sh; 184 | shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin"; 185 | }; 186 | 9740EEB61CF901F6004384FC /* Run Script */ = { 187 | isa = PBXShellScriptBuildPhase; 188 | buildActionMask = 2147483647; 189 | files = ( 190 | ); 191 | inputPaths = ( 192 | ); 193 | name = "Run Script"; 194 | outputPaths = ( 195 | ); 196 | runOnlyForDeploymentPostprocessing = 0; 197 | shellPath = /bin/sh; 198 | shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build"; 199 | }; 200 | /* End PBXShellScriptBuildPhase section */ 201 | 202 | /* Begin PBXSourcesBuildPhase section */ 203 | 97C146EA1CF9000F007C117D /* Sources */ = { 204 | isa = PBXSourcesBuildPhase; 205 | buildActionMask = 2147483647; 206 | files = ( 207 | 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */, 208 | 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */, 209 | ); 210 | runOnlyForDeploymentPostprocessing = 0; 211 | }; 212 | /* End PBXSourcesBuildPhase section */ 213 | 214 | /* Begin PBXVariantGroup section */ 215 | 97C146FA1CF9000F007C117D /* Main.storyboard */ = { 216 | isa = PBXVariantGroup; 217 | children = ( 218 | 97C146FB1CF9000F007C117D /* Base */, 219 | ); 220 | name = Main.storyboard; 221 | sourceTree = ""; 222 | }; 223 | 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */ = { 224 | isa = PBXVariantGroup; 225 | children = ( 226 | 97C147001CF9000F007C117D /* Base */, 227 | ); 228 | name = LaunchScreen.storyboard; 229 | sourceTree = ""; 230 | }; 231 | /* End PBXVariantGroup section */ 232 | 233 | /* Begin XCBuildConfiguration section */ 234 | 249021D3217E4FDB00AE95B9 /* Profile */ = { 235 | isa = XCBuildConfiguration; 236 | buildSettings = { 237 | ALWAYS_SEARCH_USER_PATHS = NO; 238 | CLANG_ANALYZER_NONNULL = YES; 239 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 240 | CLANG_CXX_LIBRARY = "libc++"; 241 | CLANG_ENABLE_MODULES = YES; 242 | CLANG_ENABLE_OBJC_ARC = YES; 243 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 244 | CLANG_WARN_BOOL_CONVERSION = YES; 245 | CLANG_WARN_COMMA = YES; 246 | CLANG_WARN_CONSTANT_CONVERSION = YES; 247 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 248 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 249 | CLANG_WARN_EMPTY_BODY = YES; 250 | CLANG_WARN_ENUM_CONVERSION = YES; 251 | CLANG_WARN_INFINITE_RECURSION = YES; 252 | CLANG_WARN_INT_CONVERSION = YES; 253 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 254 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 255 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 256 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 257 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 258 | CLANG_WARN_STRICT_PROTOTYPES = YES; 259 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 260 | CLANG_WARN_UNREACHABLE_CODE = YES; 261 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 262 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 263 | COPY_PHASE_STRIP = NO; 264 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 265 | ENABLE_NS_ASSERTIONS = NO; 266 | ENABLE_STRICT_OBJC_MSGSEND = YES; 267 | GCC_C_LANGUAGE_STANDARD = gnu99; 268 | GCC_NO_COMMON_BLOCKS = YES; 269 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 270 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 271 | GCC_WARN_UNDECLARED_SELECTOR = YES; 272 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 273 | GCC_WARN_UNUSED_FUNCTION = YES; 274 | GCC_WARN_UNUSED_VARIABLE = YES; 275 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 276 | MTL_ENABLE_DEBUG_INFO = NO; 277 | SDKROOT = iphoneos; 278 | SUPPORTED_PLATFORMS = iphoneos; 279 | TARGETED_DEVICE_FAMILY = "1,2"; 280 | VALIDATE_PRODUCT = YES; 281 | }; 282 | name = Profile; 283 | }; 284 | 249021D4217E4FDB00AE95B9 /* Profile */ = { 285 | isa = XCBuildConfiguration; 286 | baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; 287 | buildSettings = { 288 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 289 | CLANG_ENABLE_MODULES = YES; 290 | CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; 291 | ENABLE_BITCODE = NO; 292 | INFOPLIST_FILE = Runner/Info.plist; 293 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 294 | PRODUCT_BUNDLE_IDENTIFIER = com.example.flutter_template_plus; 295 | PRODUCT_NAME = "$(TARGET_NAME)"; 296 | SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; 297 | SWIFT_VERSION = 5.0; 298 | VERSIONING_SYSTEM = "apple-generic"; 299 | }; 300 | name = Profile; 301 | }; 302 | 97C147031CF9000F007C117D /* Debug */ = { 303 | isa = XCBuildConfiguration; 304 | buildSettings = { 305 | ALWAYS_SEARCH_USER_PATHS = NO; 306 | CLANG_ANALYZER_NONNULL = YES; 307 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 308 | CLANG_CXX_LIBRARY = "libc++"; 309 | CLANG_ENABLE_MODULES = YES; 310 | CLANG_ENABLE_OBJC_ARC = YES; 311 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 312 | CLANG_WARN_BOOL_CONVERSION = YES; 313 | CLANG_WARN_COMMA = YES; 314 | CLANG_WARN_CONSTANT_CONVERSION = YES; 315 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 316 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 317 | CLANG_WARN_EMPTY_BODY = YES; 318 | CLANG_WARN_ENUM_CONVERSION = YES; 319 | CLANG_WARN_INFINITE_RECURSION = YES; 320 | CLANG_WARN_INT_CONVERSION = YES; 321 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 322 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 323 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 324 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 325 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 326 | CLANG_WARN_STRICT_PROTOTYPES = YES; 327 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 328 | CLANG_WARN_UNREACHABLE_CODE = YES; 329 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 330 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 331 | COPY_PHASE_STRIP = NO; 332 | DEBUG_INFORMATION_FORMAT = dwarf; 333 | ENABLE_STRICT_OBJC_MSGSEND = YES; 334 | ENABLE_TESTABILITY = YES; 335 | GCC_C_LANGUAGE_STANDARD = gnu99; 336 | GCC_DYNAMIC_NO_PIC = NO; 337 | GCC_NO_COMMON_BLOCKS = YES; 338 | GCC_OPTIMIZATION_LEVEL = 0; 339 | GCC_PREPROCESSOR_DEFINITIONS = ( 340 | "DEBUG=1", 341 | "$(inherited)", 342 | ); 343 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 344 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 345 | GCC_WARN_UNDECLARED_SELECTOR = YES; 346 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 347 | GCC_WARN_UNUSED_FUNCTION = YES; 348 | GCC_WARN_UNUSED_VARIABLE = YES; 349 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 350 | MTL_ENABLE_DEBUG_INFO = YES; 351 | ONLY_ACTIVE_ARCH = YES; 352 | SDKROOT = iphoneos; 353 | TARGETED_DEVICE_FAMILY = "1,2"; 354 | }; 355 | name = Debug; 356 | }; 357 | 97C147041CF9000F007C117D /* Release */ = { 358 | isa = XCBuildConfiguration; 359 | buildSettings = { 360 | ALWAYS_SEARCH_USER_PATHS = NO; 361 | CLANG_ANALYZER_NONNULL = YES; 362 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 363 | CLANG_CXX_LIBRARY = "libc++"; 364 | CLANG_ENABLE_MODULES = YES; 365 | CLANG_ENABLE_OBJC_ARC = YES; 366 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 367 | CLANG_WARN_BOOL_CONVERSION = YES; 368 | CLANG_WARN_COMMA = YES; 369 | CLANG_WARN_CONSTANT_CONVERSION = YES; 370 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 371 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 372 | CLANG_WARN_EMPTY_BODY = YES; 373 | CLANG_WARN_ENUM_CONVERSION = YES; 374 | CLANG_WARN_INFINITE_RECURSION = YES; 375 | CLANG_WARN_INT_CONVERSION = YES; 376 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 377 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 378 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 379 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 380 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 381 | CLANG_WARN_STRICT_PROTOTYPES = YES; 382 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 383 | CLANG_WARN_UNREACHABLE_CODE = YES; 384 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 385 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 386 | COPY_PHASE_STRIP = NO; 387 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 388 | ENABLE_NS_ASSERTIONS = NO; 389 | ENABLE_STRICT_OBJC_MSGSEND = YES; 390 | GCC_C_LANGUAGE_STANDARD = gnu99; 391 | GCC_NO_COMMON_BLOCKS = YES; 392 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 393 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 394 | GCC_WARN_UNDECLARED_SELECTOR = YES; 395 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 396 | GCC_WARN_UNUSED_FUNCTION = YES; 397 | GCC_WARN_UNUSED_VARIABLE = YES; 398 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 399 | MTL_ENABLE_DEBUG_INFO = NO; 400 | SDKROOT = iphoneos; 401 | SUPPORTED_PLATFORMS = iphoneos; 402 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 403 | TARGETED_DEVICE_FAMILY = "1,2"; 404 | VALIDATE_PRODUCT = YES; 405 | }; 406 | name = Release; 407 | }; 408 | 97C147061CF9000F007C117D /* Debug */ = { 409 | isa = XCBuildConfiguration; 410 | baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; 411 | buildSettings = { 412 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 413 | CLANG_ENABLE_MODULES = YES; 414 | CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; 415 | ENABLE_BITCODE = NO; 416 | INFOPLIST_FILE = Runner/Info.plist; 417 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 418 | PRODUCT_BUNDLE_IDENTIFIER = com.example.flutter_template_plus; 419 | PRODUCT_NAME = "$(TARGET_NAME)"; 420 | SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; 421 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 422 | SWIFT_VERSION = 5.0; 423 | VERSIONING_SYSTEM = "apple-generic"; 424 | }; 425 | name = Debug; 426 | }; 427 | 97C147071CF9000F007C117D /* Release */ = { 428 | isa = XCBuildConfiguration; 429 | baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; 430 | buildSettings = { 431 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 432 | CLANG_ENABLE_MODULES = YES; 433 | CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; 434 | ENABLE_BITCODE = NO; 435 | INFOPLIST_FILE = Runner/Info.plist; 436 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 437 | PRODUCT_BUNDLE_IDENTIFIER = com.example.flutter_template_plus; 438 | PRODUCT_NAME = "$(TARGET_NAME)"; 439 | SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; 440 | SWIFT_VERSION = 5.0; 441 | VERSIONING_SYSTEM = "apple-generic"; 442 | }; 443 | name = Release; 444 | }; 445 | /* End XCBuildConfiguration section */ 446 | 447 | /* Begin XCConfigurationList section */ 448 | 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */ = { 449 | isa = XCConfigurationList; 450 | buildConfigurations = ( 451 | 97C147031CF9000F007C117D /* Debug */, 452 | 97C147041CF9000F007C117D /* Release */, 453 | 249021D3217E4FDB00AE95B9 /* Profile */, 454 | ); 455 | defaultConfigurationIsVisible = 0; 456 | defaultConfigurationName = Release; 457 | }; 458 | 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */ = { 459 | isa = XCConfigurationList; 460 | buildConfigurations = ( 461 | 97C147061CF9000F007C117D /* Debug */, 462 | 97C147071CF9000F007C117D /* Release */, 463 | 249021D4217E4FDB00AE95B9 /* Profile */, 464 | ); 465 | defaultConfigurationIsVisible = 0; 466 | defaultConfigurationName = Release; 467 | }; 468 | /* End XCConfigurationList section */ 469 | }; 470 | rootObject = 97C146E61CF9000F007C117D /* Project object */; 471 | } 472 | -------------------------------------------------------------------------------- /ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreviewsEnabled 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /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.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreviewsEnabled 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /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/un-pany/flutter-template-plus/381b884e58ffd7f6ebfb884fe8d46e4d4f6fb853/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/un-pany/flutter-template-plus/381b884e58ffd7f6ebfb884fe8d46e4d4f6fb853/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/un-pany/flutter-template-plus/381b884e58ffd7f6ebfb884fe8d46e4d4f6fb853/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/un-pany/flutter-template-plus/381b884e58ffd7f6ebfb884fe8d46e4d4f6fb853/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/un-pany/flutter-template-plus/381b884e58ffd7f6ebfb884fe8d46e4d4f6fb853/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/un-pany/flutter-template-plus/381b884e58ffd7f6ebfb884fe8d46e4d4f6fb853/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/un-pany/flutter-template-plus/381b884e58ffd7f6ebfb884fe8d46e4d4f6fb853/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/un-pany/flutter-template-plus/381b884e58ffd7f6ebfb884fe8d46e4d4f6fb853/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/un-pany/flutter-template-plus/381b884e58ffd7f6ebfb884fe8d46e4d4f6fb853/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/un-pany/flutter-template-plus/381b884e58ffd7f6ebfb884fe8d46e4d4f6fb853/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/un-pany/flutter-template-plus/381b884e58ffd7f6ebfb884fe8d46e4d4f6fb853/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/un-pany/flutter-template-plus/381b884e58ffd7f6ebfb884fe8d46e4d4f6fb853/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/un-pany/flutter-template-plus/381b884e58ffd7f6ebfb884fe8d46e4d4f6fb853/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/un-pany/flutter-template-plus/381b884e58ffd7f6ebfb884fe8d46e4d4f6fb853/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/un-pany/flutter-template-plus/381b884e58ffd7f6ebfb884fe8d46e4d4f6fb853/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/un-pany/flutter-template-plus/381b884e58ffd7f6ebfb884fe8d46e4d4f6fb853/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/un-pany/flutter-template-plus/381b884e58ffd7f6ebfb884fe8d46e4d4f6fb853/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/un-pany/flutter-template-plus/381b884e58ffd7f6ebfb884fe8d46e4d4f6fb853/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_template_plus 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/common/my_color.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | /// 全局颜色 4 | 5 | class MyColor { 6 | // 主题色 7 | static const MaterialColor primary = Colors.indigo; 8 | 9 | // 纯白色 10 | static const MaterialColor white = const MaterialColor( 11 | 0xFFFFFFFF, 12 | { 13 | 50: Color(0xFFFFFFFF), 14 | 100: Color(0xFFFFFFFF), 15 | 200: Color(0xFFFFFFFF), 16 | 300: Color(0xFFFFFFFF), 17 | 400: Color(0xFFFFFFFF), 18 | 500: Color(0xFFFFFFFF), 19 | 600: Color(0xFFFFFFFF), 20 | 700: Color(0xFFFFFFFF), 21 | 800: Color(0xFFFFFFFF), 22 | 900: Color(0xFFFFFFFF), 23 | }, 24 | ); 25 | 26 | // Dark Mode 相关 27 | static const Color light_red = Color(0xFFFF4759); 28 | static const Color dark_red = Color(0xFFE03E4E); 29 | static const Color dark_bg = Color(0xFF18191A); 30 | } 31 | -------------------------------------------------------------------------------- /lib/common/my_constants.dart: -------------------------------------------------------------------------------- 1 | /// 常量 2 | class Constants { 3 | // token 4 | static const String token = "X-Access-Token"; 5 | // theme 6 | static const String themeMode = "theme-mode"; 7 | } 8 | -------------------------------------------------------------------------------- /lib/common/my_init.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_easyloading/flutter_easyloading.dart'; 2 | import 'package:flutter_template_plus/db/my_cache.dart'; 3 | 4 | /// 全局初始化数据 5 | 6 | class MyInit { 7 | static Future init() async { 8 | // 预初始化 SharedPreferences 9 | await MyCache.preInit(); 10 | 11 | // 配置 EasyLoading 单例 12 | EasyLoading.instance 13 | ..displayDuration = const Duration(milliseconds: 2000) 14 | // 期间是否允许用户操作 15 | ..userInteractions = false 16 | // 点击背景是否关闭 17 | ..dismissOnTap = false 18 | // 遮蔽层 19 | ..maskType = EasyLoadingMaskType.black 20 | // Toast 出现的位置 21 | ..toastPosition = EasyLoadingToastPosition.bottom; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /lib/common/my_state.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | /// 页面状态异常管理 4 | /// 主要解决页面销毁后,调用了 setState 导致控制台警告的问题 5 | /// 该脚手架暂时未用到 6 | abstract class MyState extends State { 7 | @override 8 | void setState(fn) { 9 | if (mounted) { 10 | // 页面已装载 11 | super.setState(fn); 12 | } else { 13 | print('MyState: 页面已销毁,本次 setState 不执行: ${toString()}'); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /lib/db/my_cache.dart: -------------------------------------------------------------------------------- 1 | import 'package:shared_preferences/shared_preferences.dart'; 2 | 3 | /// 缓存管理类(基于 shared_preferences) 4 | class MyCache { 5 | static MyCache? _instance; 6 | SharedPreferences? prefs; 7 | 8 | MyCache._() { 9 | init(); 10 | } 11 | 12 | MyCache._pre(SharedPreferences prefs) { 13 | this.prefs = prefs; 14 | } 15 | 16 | // 预初始化,防止在使用时,prefs 还未完成初始化 17 | // 可以在全局(如 main.dart)先执行 preInit 方法 18 | static Future preInit() async { 19 | if (_instance == null) { 20 | SharedPreferences prefs = await SharedPreferences.getInstance(); 21 | _instance = MyCache._pre(prefs); 22 | } 23 | return _instance!; 24 | } 25 | 26 | static MyCache getInstance() { 27 | if (_instance == null) { 28 | _instance = MyCache._(); 29 | } 30 | return _instance!; 31 | } 32 | 33 | void init() async { 34 | if (prefs == null) { 35 | prefs = await SharedPreferences.getInstance(); 36 | } 37 | } 38 | 39 | // 常用 set 方法 40 | setString(String key, String value) { 41 | prefs?.setString(key, value); 42 | } 43 | 44 | setDouble(String key, double value) { 45 | prefs?.setDouble(key, value); 46 | } 47 | 48 | setInt(String key, int value) { 49 | prefs?.setInt(key, value); 50 | } 51 | 52 | setBool(String key, bool value) { 53 | prefs?.setBool(key, value); 54 | } 55 | 56 | setStringList(String key, List value) { 57 | prefs?.setStringList(key, value); 58 | } 59 | 60 | remove(String key) { 61 | prefs?.remove(key); 62 | } 63 | 64 | // get 方法 65 | T? get(String key) { 66 | var result = prefs?.get(key); 67 | if (result != null) { 68 | return result as T; 69 | } 70 | return null; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /lib/http/adapter/dio_adapter.dart: -------------------------------------------------------------------------------- 1 | import 'package:dio/dio.dart'; 2 | import 'package:flutter_template_plus/http/core/my_net_adapter.dart'; 3 | import 'package:flutter_template_plus/http/core/my_net_error.dart'; 4 | import 'package:flutter_template_plus/http/core/my_base_request.dart'; 5 | 6 | /// Dio 适配器 7 | class DioAdapter extends MyNetAdapter { 8 | @override 9 | Future> send(MyBaseRequest request) async { 10 | var response; 11 | var error; 12 | var options = Options(headers: request.header); 13 | try { 14 | switch (request.httpMethod()) { 15 | case HttpMethod.GET: 16 | response = await Dio().get( 17 | request.url(), 18 | options: options, 19 | ); 20 | break; 21 | case HttpMethod.POST: 22 | response = await Dio().post( 23 | request.url(), 24 | data: request.params, 25 | options: options, 26 | ); 27 | break; 28 | case HttpMethod.PUT: 29 | response = await Dio().put( 30 | request.url(), 31 | data: request.params, 32 | options: options, 33 | ); 34 | break; 35 | case HttpMethod.DELETE: 36 | response = await Dio().delete( 37 | request.url(), 38 | data: request.params, 39 | options: options, 40 | ); 41 | break; 42 | } 43 | } on DioError catch (e) { 44 | error = e; 45 | response = e.response; 46 | } 47 | if (error != null) { 48 | // 抛出 MyNetError 49 | throw MyNetError( 50 | response?.statusCode ?? -1, 51 | error.toString(), 52 | data: buildRes(response, request), 53 | ); 54 | } 55 | return buildRes(response, request); 56 | } 57 | 58 | // 构建 MyNetResponse 59 | MyNetResponse buildRes(Response? response, MyBaseRequest request) { 60 | return MyNetResponse( 61 | data: response?.data, 62 | request: request, 63 | statusCode: response?.statusCode, 64 | statusMessage: response?.statusMessage, 65 | extra: response, 66 | ); 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /lib/http/adapter/mock_adapter.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_template_plus/http/core/my_net_adapter.dart'; 2 | import 'package:flutter_template_plus/http/core/my_base_request.dart'; 3 | 4 | /// 测试适配器,mock 数据 5 | /// 在没有后端接口时,可用该适配器模拟测试整个发送 http 流程 6 | /// 实际生产环境中,请使用 dio_adapter 7 | 8 | class MockAdapter extends MyNetAdapter { 9 | @override 10 | Future> send(MyBaseRequest request) { 11 | return Future>.delayed(Duration(milliseconds: 1000), () { 12 | return MyNetResponse( 13 | data: { 14 | 'code': 20000, 15 | 'message': 'message', 16 | 'data': {'accessToken': 'Token'} 17 | } as T, 18 | statusCode: 200, 19 | ); 20 | }); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /lib/http/core/my_base_request.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_template_plus/common/my_constants.dart'; 2 | import 'package:flutter_template_plus/http/dao/login_dao.dart'; 3 | 4 | /// RESTful 请求 5 | enum HttpMethod { GET, POST, DELETE, PUT } 6 | 7 | /// 基础请求 8 | abstract class MyBaseRequest { 9 | // path 参数 10 | var pathParams; 11 | // 默认查询参数 12 | Map params = Map(); 13 | // 是否为 https,默认为 true 14 | bool useHttps = true; 15 | // 默认 header 数据 16 | Map header = Map(); 17 | 18 | // 设置请求方法 19 | HttpMethod httpMethod(); 20 | // 设置 path 21 | String path(); 22 | // 设置接口是否需要登录 23 | bool needLogin(); 24 | 25 | // 默认域名 26 | String authority() { 27 | return 'vue-typescript-admin-mock-server-armour.vercel.app'; 28 | } 29 | 30 | // 生成具体的 url 31 | String url() { 32 | Uri uri; 33 | var pathStr = path(); 34 | // 拼接 path 参数 35 | if (pathParams != null) { 36 | if (path().endsWith('/')) { 37 | pathStr = '${path()}$pathParams'; 38 | } else { 39 | pathStr = '${path()}/$pathParams'; 40 | } 41 | } 42 | // http 和 https 的切换 43 | if (useHttps) { 44 | uri = Uri.https(authority(), pathStr, params); 45 | } else { 46 | uri = Uri.http(authority(), pathStr, params); 47 | } 48 | // 设置 token 49 | var token = LoginDao.getToken(); 50 | if (needLogin() && token != null) { 51 | // 给需要登录的接口携带登录令牌 52 | addHeader(Constants.token, token); 53 | } 54 | return uri.toString(); 55 | } 56 | 57 | // 添加查询参数 58 | MyBaseRequest add(String k, Object v) { 59 | params[k] = v.toString(); 60 | return this; 61 | } 62 | 63 | // 添加 header 数据 64 | MyBaseRequest addHeader(String k, Object v) { 65 | header[k] = v.toString(); 66 | return this; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /lib/http/core/my_net.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_template_plus/http/core/my_net_adapter.dart'; 2 | import 'package:flutter_template_plus/http/core/my_net_error.dart'; 3 | import 'package:flutter_template_plus/http/adapter/dio_adapter.dart'; 4 | import 'package:flutter_template_plus/http/core/my_base_request.dart'; 5 | import 'package:flutter_template_plus/http/dao/login_dao.dart'; 6 | import 'package:flutter_template_plus/navigator/my_navigator.dart'; 7 | import 'package:flutter_template_plus/navigator/my_navigator_util.dart'; 8 | 9 | /// 支持第三方网络库插拔设计(当前架构选用 Dio),且不干扰业务层 10 | /// 简洁易用,基于配置进行请求 11 | /// Adapter 设计,扩展性强 12 | /// 统一异常和返回处理 13 | class MyNet { 14 | MyNet._(); 15 | // 懒汉模式 16 | static MyNet? _instance; 17 | static MyNet getInstance() { 18 | if (_instance == null) { 19 | _instance = MyNet._(); 20 | } 21 | return _instance!; 22 | } 23 | 24 | Future fire(MyBaseRequest request) async { 25 | MyNetResponse? response; 26 | var error; 27 | try { 28 | response = await send(request); 29 | } on MyNetError catch (e) { 30 | error = e; 31 | response = e.data; 32 | printLog('异常信息:${e.message}'); 33 | } catch (e) { 34 | // 其他异常 35 | error = e; 36 | printLog('其他异常:$e'); 37 | } 38 | 39 | if (response == null) { 40 | printLog(error); 41 | } 42 | 43 | var result = response?.data; 44 | printLog('请求结果:$result'); 45 | 46 | // http 状态码 47 | int? statusCode = response?.statusCode; 48 | // 业务状态码(这要求后端接口严格按着统一的格式返回,这里要求必须返回业务 code) 49 | int? code = result != null ? result['code'] : null; 50 | // http 状态码拦截器 51 | return statusCodeInterceptor(statusCode, code, result); 52 | } 53 | 54 | Future send(MyBaseRequest request) async { 55 | // 使用 mock 发送请求 56 | // MyNetAdapter adapter = MockAdapter(); 57 | 58 | // 使用 Dio 发送请求 59 | MyNetAdapter adapter = DioAdapter(); 60 | return adapter.send(request); 61 | } 62 | 63 | // http 状态码拦截器 64 | statusCodeInterceptor(int? statusCode, code, result) { 65 | switch (statusCode) { 66 | case 200: 67 | // 当 'http 状态码' == 200 时,根据具体的业务,在这里统一解析'业务状态码' 68 | return codeInterceptor(code, result); 69 | case 401: 70 | // 删除失效的 Token 71 | LoginDao.removeToken(); 72 | // 调起登录页 73 | MyNavigator.getInstance().onJumpTo(RouteStatus.login); 74 | throw NeedLogin(); 75 | case 403: 76 | // 删除失效的 Token 77 | LoginDao.removeToken(); 78 | // 调起登录页 79 | MyNavigator.getInstance().onJumpTo(RouteStatus.login); 80 | throw NeedAuth(result.toString(), data: result); 81 | case null: 82 | throw MyNetError(-1, '网络异常', data: result); 83 | default: 84 | throw MyNetError(statusCode ?? -1, result.toString(), data: result); 85 | } 86 | } 87 | 88 | // 业务状态码拦截器 89 | codeInterceptor(code, result) { 90 | switch (code) { 91 | // 业务状态码 20000,代表成功 92 | case 20000: 93 | return result; 94 | default: 95 | throw MyNetError(code ?? -1, result.toString(), data: result); 96 | } 97 | } 98 | 99 | void printLog(log) { 100 | print('my_net:${log.toString()}'); 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /lib/http/core/my_net_adapter.dart: -------------------------------------------------------------------------------- 1 | import 'dart:convert'; 2 | import 'package:flutter_template_plus/http/core/my_base_request.dart'; 3 | 4 | /// 网络请求抽象类 5 | abstract class MyNetAdapter { 6 | Future> send(MyBaseRequest request); 7 | } 8 | 9 | /// 统一网络返回格式 10 | class MyNetResponse { 11 | T? data; 12 | // 请求 13 | MyBaseRequest? request; 14 | // http 状态码 15 | int? statusCode; 16 | // http Message 17 | String? statusMessage; 18 | // 其他 19 | dynamic extra; 20 | 21 | MyNetResponse({ 22 | this.data, 23 | this.request, 24 | this.statusCode, 25 | this.statusMessage, 26 | this.extra, 27 | }); 28 | 29 | @override 30 | String toString() { 31 | if (data is Map) { 32 | return json.encode(data); 33 | } 34 | return data.toString(); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /lib/http/core/my_net_error.dart: -------------------------------------------------------------------------------- 1 | /// 网络异常统一格式类 2 | class MyNetError implements Exception { 3 | MyNetError(this.code, this.message, {this.data}); 4 | // 异常码 5 | final int code; 6 | // 异常消息 7 | final String message; 8 | // 异常数据 9 | final dynamic data; 10 | } 11 | 12 | /// 需要登录的异常 13 | class NeedLogin extends MyNetError { 14 | NeedLogin({ 15 | int code: 401, 16 | String message: '请先登录', 17 | }) : super(code, message); 18 | } 19 | 20 | /// 需要授权的异常 21 | class NeedAuth extends MyNetError { 22 | NeedAuth( 23 | String message, { 24 | int code: 403, 25 | dynamic data, 26 | }) : super(code, message, data: data); 27 | } 28 | -------------------------------------------------------------------------------- /lib/http/dao/login_dao.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_template_plus/common/my_constants.dart'; 2 | import 'package:flutter_template_plus/db/my_cache.dart'; 3 | import 'package:flutter_template_plus/http/core/my_net.dart'; 4 | import 'package:flutter_template_plus/http/request/login_request.dart'; 5 | 6 | /// 数据访问对象层,与服务端交互的部分,可以放在 Dao 层 7 | 8 | class LoginDao { 9 | // 登录 10 | static Future login(String username, String password) async { 11 | // 创建请求 12 | LoginRequest request = LoginRequest(); 13 | // 向请求中添加查询参数 14 | request.add('username', username).add('password', password); 15 | // 发送请求 16 | var res = await MyNet.getInstance().fire(request); 17 | // 保存登录令牌 18 | setToken(res['data']['accessToken']); 19 | return res; 20 | } 21 | 22 | // 保存登录令牌 23 | static setToken(text) { 24 | MyCache.getInstance().setString(Constants.token, text); 25 | } 26 | 27 | // 获取登录令牌 28 | static String? getToken() { 29 | return MyCache.getInstance().get(Constants.token); 30 | } 31 | 32 | // 删除登录令牌 33 | static removeToken() { 34 | return MyCache.getInstance().remove(Constants.token); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /lib/http/request/login_request.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_template_plus/http/core/my_base_request.dart'; 2 | 3 | class LoginRequest extends MyBaseRequest { 4 | 5 | // 请求类型 6 | @override 7 | HttpMethod httpMethod() { 8 | return HttpMethod.POST; 9 | } 10 | 11 | // 访问该接口是否需要先登录 12 | @override 13 | bool needLogin() { 14 | return false; 15 | } 16 | 17 | // 该接口 path 18 | @override 19 | String path() { 20 | return '/mock-api/v1/users/login'; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /lib/main.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_easyloading/flutter_easyloading.dart'; 3 | import 'package:flutter_localizations/flutter_localizations.dart'; 4 | import 'package:flutter_template_plus/common/my_init.dart'; 5 | import 'package:flutter_template_plus/provider/my_provider.dart'; 6 | import 'package:flutter_template_plus/provider/theme_provider.dart'; 7 | import 'package:provider/provider.dart'; 8 | import 'navigator/my_router_delegate.dart'; 9 | 10 | void main() { 11 | // 网格线 12 | // debugPaintSizeEnabled = true; 13 | // Flutter 版本 (1.12.13+hotfix.5) 后,初始化插件必须加 ensureInitialized 14 | // WidgetsFlutterBinding.ensureInitialized(); 15 | // 应用入口 16 | runApp(MyApp()); 17 | } 18 | 19 | class MyApp extends StatefulWidget { 20 | const MyApp({Key? key}) : super(key: key); 21 | 22 | @override 23 | _MyAppState createState() => _MyAppState(); 24 | } 25 | 26 | class _MyAppState extends State { 27 | MyRouterDelegate _routerDelegate = MyRouterDelegate(); 28 | 29 | @override 30 | Widget build(BuildContext context) { 31 | return FutureBuilder( 32 | // 进行项目的预初始化 33 | future: MyInit.init(), 34 | builder: (BuildContext context, AsyncSnapshot snapshot) { 35 | Widget widget = snapshot.connectionState == ConnectionState.done 36 | // 定义 Router(Navigator 2.0 的概念) 37 | ? Router(routerDelegate: _routerDelegate) 38 | // 初始化未完成时,显示 loading 动画 39 | : Scaffold(body: Center(child: CircularProgressIndicator())); 40 | 41 | return MultiProvider( 42 | providers: topProviders, 43 | // 这里通过 Consumer 读取数据,灵活度高 44 | // 还有其他的读取方式,比如 context.read() 45 | child: Consumer( 46 | builder: ( 47 | BuildContext context, 48 | ThemeProvider themeProvider, 49 | Widget? child, 50 | ) { 51 | return MaterialApp( 52 | title: 'flutter_template_plus', 53 | theme: themeProvider.getTheme(), 54 | darkTheme: themeProvider.getTheme(isDarkMode: true), 55 | themeMode: themeProvider.getThemeMode(), 56 | localizationsDelegates: [ 57 | // 本地化的代理类 58 | GlobalMaterialLocalizations.delegate, 59 | GlobalWidgetsLocalizations.delegate, 60 | ], 61 | supportedLocales: [ 62 | const Locale('en', 'US'), // 美国英语 63 | const Locale('zh', 'CH'), // 中文简体 64 | ], 65 | builder: EasyLoading.init(), 66 | // 设置 Router 67 | home: widget, 68 | ); 69 | }, 70 | ), 71 | ); 72 | }, 73 | ); 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /lib/models/demo_model.dart: -------------------------------------------------------------------------------- 1 | class DemoModel { 2 | String? name; 3 | String? mail; 4 | 5 | DemoModel({this.name, this.mail}); 6 | 7 | DemoModel.fromJson(Map json) { 8 | name = json['name']; 9 | mail = json['mail']; 10 | } 11 | 12 | Map toJson() { 13 | final Map data = new Map(); 14 | data['name'] = this.name; 15 | data['mail'] = this.mail; 16 | return data; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /lib/navigator/my_navigator.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_template_plus/navigator/my_navigator_util.dart'; 3 | import 'package:flutter_template_plus/pages/navigator_page.dart'; 4 | 5 | /// 监听路由页面跳转,感知当前页面是否压后台 6 | class MyNavigator extends AbstractRouteJumpListener { 7 | static MyNavigator? _instance; 8 | 9 | RouteJumpListener? _routeJump; 10 | List _listeners = []; 11 | RouteStatusInfo? _current; 12 | 13 | // 导航页底部 tab 14 | RouteStatusInfo? _bottomTab; 15 | 16 | MyNavigator._(); 17 | 18 | // 单例模式 19 | static MyNavigator getInstance() { 20 | if (_instance == null) { 21 | _instance = MyNavigator._(); 22 | } 23 | return _instance!; 24 | } 25 | 26 | // 导航页底部 tab 切换监听 27 | void onBottomTabChange(int index, Widget page) { 28 | _bottomTab = RouteStatusInfo(RouteStatus.navigator, page); 29 | _notify(_bottomTab!); 30 | } 31 | 32 | // 注册路由跳转逻辑 33 | void registerRouteJump(RouteJumpListener routeJumpListener) { 34 | this._routeJump = routeJumpListener; 35 | } 36 | 37 | // 监听路由页面跳转 38 | void addListener(RouteChangeListener listener) { 39 | // 如果没有添加过则添加进去 40 | if (!_listeners.contains(listener)) { 41 | _listeners.add(listener); 42 | } 43 | } 44 | 45 | // 移除监听 46 | void removeListener(RouteChangeListener listener) { 47 | _listeners.remove(listener); 48 | } 49 | 50 | // 切换路由 51 | @override 52 | void onJumpTo(RouteStatus routeStatus, {Map? args}) { 53 | _routeJump?.onJumpTo(routeStatus, args: args); 54 | } 55 | 56 | // 通知路由页面变化,currentPages 当前页面堆栈,prePages 变化前的页面堆栈 57 | void notify(List currentPages, List prePages) { 58 | // 如果没有变化,则不做处理,直接 return 59 | if (currentPages == prePages) return; 60 | var current = RouteStatusInfo( 61 | getStatus(currentPages.last), 62 | currentPages.last.child, 63 | ); 64 | _notify(current); 65 | } 66 | 67 | void _notify(RouteStatusInfo current) { 68 | if (current.page is NavigatorPage && _bottomTab != null) { 69 | // 如果打开的是导航页,则明确到导航页具体的 tab 70 | current = _bottomTab!; 71 | } 72 | print('my_navigator:当前页面:${current.page}'); 73 | print('my_navigator:上一个页面:${_current?.page}'); 74 | _listeners.forEach((listener) { 75 | listener(current, _current); 76 | }); 77 | _current = current; 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /lib/navigator/my_navigator_util.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_template_plus/pages/detail_page.dart'; 3 | import 'package:flutter_template_plus/pages/login_page.dart'; 4 | import 'package:flutter_template_plus/pages/navigator_page.dart'; 5 | 6 | /// 路由状态,unknown 代表未知的页面 7 | enum RouteStatus { login, navigator, detail, unknown } 8 | 9 | /// 创建 Page 10 | pageWrap(Widget child) { 11 | return MaterialPage( 12 | // key 保持唯一就行 13 | key: ValueKey(child.hashCode), 14 | child: child, 15 | ); 16 | } 17 | 18 | /// 获取 Page 对应的 RouteStatus 19 | RouteStatus getStatus(MaterialPage page) { 20 | if (page.child is LoginPage) { 21 | return RouteStatus.login; 22 | } else if (page.child is NavigatorPage) { 23 | return RouteStatus.navigator; 24 | } else if (page.child is DetailPage) { 25 | return RouteStatus.detail; 26 | } else { 27 | return RouteStatus.unknown; 28 | } 29 | } 30 | 31 | /// 获取 routeStatus 在 Page 栈中的位置 32 | int getPageIndex(List pages, RouteStatus routeStatus) { 33 | for (int i = 0; i < pages.length; i++) { 34 | MaterialPage page = pages[i]; 35 | if (getStatus(page) == routeStatus) { 36 | return i; 37 | } 38 | } 39 | return -1; 40 | } 41 | 42 | /// 路由信息 43 | class RouteStatusInfo { 44 | final RouteStatus routeStatus; 45 | final Widget page; 46 | RouteStatusInfo(this.routeStatus, this.page); 47 | } 48 | 49 | /// current 当前页面,pre 上次的页面 50 | typedef RouteChangeListener(RouteStatusInfo current, RouteStatusInfo? pre); 51 | 52 | /// 路由跳转方法的类型 53 | typedef OnJumpTo = void Function(RouteStatus routeStatus, {Map? args}); 54 | 55 | /// 定义路由跳转逻辑要实现的功能 56 | class RouteJumpListener { 57 | final OnJumpTo onJumpTo; 58 | RouteJumpListener({required this.onJumpTo}); 59 | } 60 | 61 | /// 抽象类供 MyNavigator 实现 62 | abstract class AbstractRouteJumpListener { 63 | // routeStatus 代表要跳转的页面,args 代表要传递的值 64 | void onJumpTo(RouteStatus routeStatus, {Map args}); 65 | } 66 | -------------------------------------------------------------------------------- /lib/navigator/my_router_delegate.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_easyloading/flutter_easyloading.dart'; 3 | import 'package:flutter_template_plus/http/dao/login_dao.dart'; 4 | import 'package:flutter_template_plus/navigator/my_navigator_util.dart'; 5 | import 'package:flutter_template_plus/pages/navigator_page.dart'; 6 | import 'package:flutter_template_plus/navigator/my_navigator.dart'; 7 | import 'package:flutter_template_plus/pages/detail_page.dart'; 8 | import 'package:flutter_template_plus/pages/login_page.dart'; 9 | 10 | /// 路由代理 11 | class MyRouterDelegate extends RouterDelegate 12 | with ChangeNotifier, PopNavigatorRouterDelegateMixin { 13 | // 构造函数 14 | MyRouterDelegate() : navigatorKey = GlobalKey() { 15 | // 注册路由跳转逻辑 16 | MyNavigator.getInstance().registerRouteJump( 17 | RouteJumpListener( 18 | onJumpTo: (RouteStatus routeStatus, {Map? args}) { 19 | _routeStatus = routeStatus; 20 | if (routeStatus == RouteStatus.detail) { 21 | // 详情页面要传递 id 参数 22 | id = args!['id']; 23 | } 24 | // notifyListeners 通知数据变化,和 setState 效果一样 25 | notifyListeners(); 26 | }, 27 | ), 28 | ); 29 | } 30 | // 为 Navigator 设置一个 key,必要时可以通过 navigatorKey.currentState 来获取到 navigatorState 对象 31 | final GlobalKey navigatorKey; 32 | // pages 存放所有页面 33 | List pages = []; 34 | // 路由状态 35 | RouteStatus _routeStatus = RouteStatus.navigator; 36 | // 要传递给详情页的 id 数据 37 | int? id; 38 | 39 | // 是否登录 40 | bool get hasLogin => LoginDao.getToken() != null; 41 | // 路由拦截 42 | RouteStatus get getRouteStatus { 43 | if (!hasLogin) { 44 | // 如果没有登录则将路由状态设置为 login 页 45 | return _routeStatus = RouteStatus.login; 46 | } else if (hasLogin && _routeStatus == RouteStatus.login) { 47 | // 如果登录了,就不允许跳转到 Login 页,重定向到 NavigatorPage 页 48 | return _routeStatus = RouteStatus.navigator; 49 | } else { 50 | return _routeStatus; 51 | } 52 | } 53 | 54 | // 管理 Page 堆栈( Navigator 2.0 的优势之一就在这个 pages 栈,能够一次导入多个页面;当前显示的页面,要将那些页面出栈等等操作都在这里管理) 55 | @override 56 | Widget build(BuildContext context) { 57 | // 获取 _routeStatus 在 Page 栈中的位置 58 | int index = getPageIndex(pages, getRouteStatus); 59 | // 临时变量 tempPages 60 | List tempPages = pages; 61 | if (index != -1) { 62 | // 要打开的页面在栈中已存在,则将该页面和它上面的所有页面进行出栈 63 | // 具体的规则可以根据需要自行进行调整,脚手架这里只要求栈中只允许有一个同样的页面的实例 64 | tempPages = tempPages.sublist(0, index); 65 | } 66 | var page; 67 | 68 | switch (getRouteStatus) { 69 | case RouteStatus.login: 70 | // 跳转 LoginPage 时将栈中其它页面进行出栈,因为 LoginPage 不可回退 71 | pages.clear(); 72 | page = pageWrap(LoginPage()); 73 | break; 74 | case RouteStatus.navigator: 75 | // 跳转 NavigatorPage 时将栈中其它页面进行出栈,因为 NavigatorPage 不可回退 76 | pages.clear(); 77 | page = pageWrap(NavigatorPage()); 78 | break; 79 | case RouteStatus.detail: 80 | page = pageWrap(DetailPage(id: id!)); 81 | break; 82 | case RouteStatus.unknown: 83 | // 未知页面 84 | break; 85 | } 86 | // 重新创建一个数组,否则 pages 因引用没有改变,路由不会生效 87 | tempPages = [...tempPages, page]; 88 | // 通知路由发生变化 89 | MyNavigator.getInstance().notify(tempPages, pages); 90 | pages = tempPages; 91 | 92 | // 返回整个路由堆栈信息 93 | return WillPopScope( 94 | // fix: Android 物理返回键,无法返回上一页问题 @https://github.com/flutter/flutter/issues/66349 95 | // WillPopScope + onWillPop 就是解决这个问题的关键 96 | onWillPop: () async { 97 | return !(await navigatorKey.currentState?.maybePop() ?? false); 98 | }, 99 | child: Navigator( 100 | key: navigatorKey, 101 | pages: pages, 102 | // 返回上一页时触犯(在这里可以控制是否返回) 103 | onPopPage: (route, result) { 104 | if (route.settings is MaterialPage) { 105 | // login 页未登录时,做一下返回拦截(防御性编程) 106 | if ((route.settings as MaterialPage).child is LoginPage) { 107 | if (!hasLogin) { 108 | EasyLoading.showInfo("请先登录"); 109 | return false; 110 | } 111 | } 112 | } 113 | // 执行返回操作 114 | if (!route.didPop(result)) { 115 | // 不可以返回 116 | return false; 117 | } 118 | var tempPages = [...pages]; 119 | pages.removeLast(); 120 | // 通知路由发生变化 121 | MyNavigator.getInstance().notify(pages, tempPages); 122 | return true; 123 | }, 124 | ), 125 | ); 126 | } 127 | 128 | @override 129 | Future setNewRoutePath(dynamic path) async {} 130 | } 131 | -------------------------------------------------------------------------------- /lib/pages/detail_page.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | class DetailPage extends StatefulWidget { 4 | final int id; 5 | 6 | const DetailPage({Key? key, required this.id}) : super(key: key); 7 | 8 | @override 9 | _DetailPageState createState() => _DetailPageState(); 10 | } 11 | 12 | class _DetailPageState extends State { 13 | @override 14 | Widget build(BuildContext context) { 15 | return Scaffold( 16 | appBar: AppBar( 17 | title: Text('详情'), 18 | ), 19 | body: Center( 20 | child: Text('传递过来的id数据: ${widget.id}'), 21 | ), 22 | ); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /lib/pages/home_page.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_template_plus/navigator/my_navigator.dart'; 3 | import 'package:flutter_template_plus/navigator/my_navigator_util.dart'; 4 | 5 | class HomePage extends StatefulWidget { 6 | const HomePage({Key? key}) : super(key: key); 7 | 8 | @override 9 | _HomePageState createState() => _HomePageState(); 10 | } 11 | 12 | class _HomePageState extends State { 13 | RouteChangeListener? listener; 14 | 15 | @override 16 | void initState() { 17 | super.initState(); 18 | // 切换路由时监听当前页面打开与离开 19 | MyNavigator.getInstance().addListener(listener = (current, pre) { 20 | if (widget == current.page || current.page is HomePage) { 21 | print('home_page:打开了当前页面,即首页'); 22 | } else if (widget == pre?.page || pre?.page is HomePage) { 23 | // 通过 NavigatorPage 的底部 Tab 切换回当前页面时,不会触发, 24 | // 这是因为 底部 Tab 切换时,重新构建了当前页,监听也随之被重新挂载, 25 | // 解决办法可以是: 可以将 NavigatorPage 页面的 body 修改为 PageView 来渲染,并且将当前页 KeepAlive 26 | print('home_page:离开了当前页面,即首页'); 27 | } 28 | }); 29 | } 30 | 31 | @override 32 | void dispose() { 33 | super.dispose(); 34 | // 记得销毁监听 35 | MyNavigator.getInstance().removeListener(listener!); 36 | } 37 | 38 | @override 39 | Widget build(BuildContext context) { 40 | return Scaffold( 41 | appBar: AppBar( 42 | title: Text('首页'), 43 | ), 44 | body: Center( 45 | child: ElevatedButton( 46 | child: Text("跳转到详情"), 47 | onPressed: () { 48 | MyNavigator.getInstance().onJumpTo( 49 | RouteStatus.detail, 50 | args: {'id': 9527}, 51 | ); 52 | }, 53 | ), 54 | ), 55 | ); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /lib/pages/login_page.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_easyloading/flutter_easyloading.dart'; 3 | import 'package:flutter_template_plus/http/core/my_net_error.dart'; 4 | import 'package:flutter_template_plus/http/dao/login_dao.dart'; 5 | import 'package:flutter_template_plus/navigator/my_navigator.dart'; 6 | import 'package:flutter_template_plus/navigator/my_navigator_util.dart'; 7 | import 'package:flutter_template_plus/widgets/login_input.dart'; 8 | 9 | class LoginPage extends StatefulWidget { 10 | LoginPage({Key? key}) : super(key: key); 11 | 12 | @override 13 | _LoginPageState createState() => _LoginPageState(); 14 | } 15 | 16 | class _LoginPageState extends State { 17 | final GlobalKey _formKey = GlobalKey(); 18 | TextEditingController _userController = TextEditingController(text: 'admin'); 19 | TextEditingController _passwordController = 20 | TextEditingController(text: '12345678'); 21 | // '记住密码' 复选框 22 | bool? _savePassword = false; 23 | 24 | @override 25 | Widget build(BuildContext context) { 26 | return Scaffold( 27 | // ListView 可以自适应键盘,防止键盘弹起后遮挡 28 | body: ListView( 29 | padding: EdgeInsets.only( 30 | top: 70, 31 | left: 35, 32 | right: 35, 33 | ), 34 | children: [ 35 | Image.asset( 36 | 'assets/images/login/logo.png', 37 | width: 200, 38 | height: 200, 39 | ), 40 | _form(), 41 | _save(), 42 | _button(), 43 | ], 44 | ), 45 | ); 46 | } 47 | 48 | // 表单 49 | Widget _form() { 50 | return Form( 51 | // 设置 globalKey,用于后面获取 FormState 52 | key: _formKey, 53 | // 不开启自动校验表单,而是选择在点击登录按钮时校验 54 | autovalidateMode: AutovalidateMode.disabled, 55 | child: Column( 56 | children: [ 57 | Padding( 58 | padding: EdgeInsets.only( 59 | bottom: 20, 60 | ), 61 | child: LoginInput( 62 | '请输入用户名', 63 | Icon(Icons.perm_identity), 64 | _userController, 65 | validator: (value) { 66 | return value!.trim().length > 0 ? null : "用户名不能为空"; 67 | }, 68 | ), 69 | ), 70 | Padding( 71 | padding: EdgeInsets.only( 72 | bottom: 20, 73 | ), 74 | child: LoginInput( 75 | '请输入密码', 76 | Icon(Icons.lock_outline), 77 | _passwordController, 78 | obscureText: true, 79 | validator: (value) { 80 | return value!.trim().length >= 8 ? null : "密码不能少于8位"; 81 | }, 82 | ), 83 | ), 84 | ], 85 | ), 86 | ); 87 | } 88 | 89 | // 记住密码 90 | _save() { 91 | return Padding( 92 | padding: EdgeInsets.only( 93 | bottom: 50, 94 | ), 95 | child: Row( 96 | mainAxisAlignment: MainAxisAlignment.end, 97 | children: [ 98 | Checkbox( 99 | value: _savePassword, 100 | onChanged: (value) { 101 | setState(() { 102 | _savePassword = value; 103 | }); 104 | }, 105 | ), 106 | Text("记住密码"), 107 | ], 108 | ), 109 | ); 110 | } 111 | 112 | // 登录按钮 113 | Widget _button() { 114 | return FractionallySizedBox( 115 | // 子元素占父元素的宽度比例 116 | widthFactor: 0.6, 117 | child: SizedBox( 118 | height: 45, 119 | child: ElevatedButton( 120 | child: Text("登录"), 121 | style: ElevatedButton.styleFrom( 122 | // 圆角 123 | shape: StadiumBorder(), 124 | ), 125 | onPressed: () async { 126 | if ((_formKey.currentState as FormState).validate()) { 127 | // 验证通过提交数据 128 | EasyLoading.show(); 129 | try { 130 | await LoginDao.login( 131 | _userController.text.trim(), 132 | _passwordController.text.trim(), 133 | ); 134 | EasyLoading.dismiss(); 135 | MyNavigator.getInstance().onJumpTo(RouteStatus.navigator); 136 | } on MyNetError catch (e) { 137 | // 请求发生异常 138 | EasyLoading.showError(e.message); 139 | } catch (e) { 140 | // 其他代码异常 141 | EasyLoading.showError(e.toString()); 142 | } 143 | } 144 | }, 145 | ), 146 | ), 147 | ); 148 | } 149 | } 150 | -------------------------------------------------------------------------------- /lib/pages/me_page.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_template_plus/http/dao/login_dao.dart'; 3 | import 'package:flutter_template_plus/navigator/my_navigator.dart'; 4 | import 'package:flutter_template_plus/navigator/my_navigator_util.dart'; 5 | import 'package:flutter_template_plus/provider/theme_provider.dart'; 6 | import 'package:provider/provider.dart'; 7 | 8 | class MePage extends StatefulWidget { 9 | const MePage({Key? key}) : super(key: key); 10 | 11 | @override 12 | _MePageState createState() => _MePageState(); 13 | } 14 | 15 | class _MePageState extends State { 16 | @override 17 | Widget build(BuildContext context) { 18 | return Scaffold( 19 | appBar: AppBar( 20 | title: Text('我的'), 21 | ), 22 | body: ListView( 23 | padding: EdgeInsets.only( 24 | left: 35, 25 | right: 35, 26 | ), 27 | children: [ 28 | OutlinedButton( 29 | child: Text("亮色模式"), 30 | onPressed: () { 31 | context.read().setThemeMode(ThemeMode.light); 32 | }, 33 | ), 34 | OutlinedButton( 35 | child: Text("黑暗模式"), 36 | onPressed: () { 37 | context.read().setThemeMode(ThemeMode.dark); 38 | }, 39 | ), 40 | OutlinedButton( 41 | child: Text("跟随系统"), 42 | onPressed: () { 43 | context.read().setThemeMode(ThemeMode.system); 44 | }, 45 | ), 46 | ElevatedButton( 47 | child: Text("退出登录"), 48 | onPressed: () { 49 | LoginDao.removeToken(); 50 | MyNavigator.getInstance().onJumpTo(RouteStatus.login); 51 | }, 52 | ), 53 | ], 54 | ), 55 | ); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /lib/pages/navigator_page.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_easyloading/flutter_easyloading.dart'; 3 | import 'package:flutter_template_plus/navigator/my_navigator.dart'; 4 | import 'package:flutter_template_plus/pages/home_page.dart'; 5 | import 'package:flutter_template_plus/pages/me_page.dart'; 6 | import 'package:flutter_template_plus/common/my_color.dart'; 7 | 8 | class NavigatorPage extends StatefulWidget { 9 | const NavigatorPage({Key? key}) : super(key: key); 10 | 11 | @override 12 | _NavigatorPageState createState() => _NavigatorPageState(); 13 | } 14 | 15 | class _NavigatorPageState extends State { 16 | // 默认的颜色 17 | final _defaultColor = Colors.grey; 18 | // 选中后的颜色 19 | final _activeColor = MyColor.primary; 20 | // 当前索引 21 | int _currentIndex = 0; 22 | // 页面 23 | final List _pages = [ 24 | HomePage(), 25 | MePage(), 26 | ]; 27 | // 是否已经 build 过了 28 | bool _hasBuild = false; 29 | // 上次点击时间 30 | DateTime? _lastPressedAt; 31 | 32 | @override 33 | Widget build(BuildContext context) { 34 | if (!_hasBuild) { 35 | // 页面第一次打开时通知打开的是哪个 tab 36 | MyNavigator.getInstance().onBottomTabChange( 37 | _currentIndex, 38 | _pages[_currentIndex], 39 | ); 40 | _hasBuild = true; 41 | } 42 | 43 | return Scaffold( 44 | body: WillPopScope( 45 | onWillPop: exitApp, 46 | child: _pages[_currentIndex], 47 | ), 48 | bottomNavigationBar: BottomNavigationBar( 49 | currentIndex: _currentIndex, 50 | type: BottomNavigationBarType.fixed, 51 | selectedItemColor: _activeColor, 52 | items: [ 53 | _bottomItem('首页', Icons.home_outlined), 54 | _bottomItem('我的', Icons.person_outline), 55 | ], 56 | onTap: (index) { 57 | MyNavigator.getInstance().onBottomTabChange(index, _pages[index]); 58 | setState(() { 59 | _currentIndex = index; 60 | }); 61 | }, 62 | ), 63 | ); 64 | } 65 | 66 | // 底部 Item 67 | BottomNavigationBarItem _bottomItem(String label, IconData icon) { 68 | return BottomNavigationBarItem( 69 | label: label, 70 | icon: Icon(icon, color: _defaultColor), 71 | activeIcon: Icon(icon, color: _activeColor), 72 | ); 73 | } 74 | 75 | // 退出 app 76 | Future exitApp() async { 77 | if (_lastPressedAt == null || 78 | DateTime.now().difference(_lastPressedAt!) > Duration(seconds: 2)) { 79 | EasyLoading.showToast('再点一次退出'); 80 | // 两次点击间隔超过2秒则重新计时 81 | _lastPressedAt = DateTime.now(); 82 | return Future.value(false); 83 | } 84 | return Future.value(true); 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /lib/provider/my_provider.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_template_plus/provider/theme_provider.dart'; 2 | import 'package:provider/provider.dart'; 3 | import 'package:provider/single_child_widget.dart'; 4 | 5 | List topProviders = [ 6 | ChangeNotifierProvider(create: (_) => ThemeProvider()) 7 | ]; -------------------------------------------------------------------------------- /lib/provider/theme_provider.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter/scheduler.dart'; 3 | import 'package:flutter_template_plus/common/my_color.dart'; 4 | import 'package:flutter_template_plus/common/my_constants.dart'; 5 | import 'package:flutter_template_plus/db/my_cache.dart'; 6 | 7 | /// 扩展 ThemeMode 8 | extension ThemeModeExtension on ThemeMode { 9 | // 这样就是可以通过 value 属性,获取对应的 String 10 | String get value => ['System', 'Light', 'Dark'][index]; 11 | } 12 | 13 | /// 主题状态管理 14 | class ThemeProvider extends ChangeNotifier { 15 | ThemeMode? _themeMode; 16 | 17 | // 判断是否是 Dark Mode(该方法用于页面上判断是否为 Dark Mode,然后切换样式) 18 | bool isDark() { 19 | if (_themeMode == ThemeMode.system) { 20 | // 获取系统的 Dark Mode 21 | return SchedulerBinding.instance?.window.platformBrightness == 22 | Brightness.dark; 23 | } 24 | return _themeMode == ThemeMode.dark; 25 | } 26 | 27 | // 获取主题模式 28 | ThemeMode getThemeMode() { 29 | String? themeMode = MyCache.getInstance().get(Constants.themeMode); 30 | switch (themeMode) { 31 | case 'System': 32 | _themeMode = ThemeMode.system; 33 | break; 34 | case 'Dark': 35 | _themeMode = ThemeMode.dark; 36 | break; 37 | default: 38 | _themeMode = ThemeMode.light; 39 | break; 40 | } 41 | return _themeMode!; 42 | } 43 | 44 | // 设置主题模式 45 | void setThemeMode(ThemeMode themeMode) { 46 | MyCache.getInstance().setString(Constants.themeMode, themeMode.value); 47 | // 主题模式改变后,需要通知所有订阅者 48 | notifyListeners(); 49 | } 50 | 51 | // 获取主题 52 | ThemeData getTheme({bool isDarkMode = false}) { 53 | var themeData = ThemeData( 54 | // 主题色 55 | primarySwatch: MyColor.primary, 56 | // 主色调(决定导航栏等颜色) 57 | // primaryColor: isDarkMode ? MyColor.dark_bg : MyColor.primary, 58 | // 亮度(深色还是浅色) 59 | brightness: isDarkMode ? Brightness.dark : Brightness.light, 60 | // 错误状态颜色(如输入框错误提示文字) 61 | errorColor: isDarkMode ? MyColor.dark_red : MyColor.light_red, 62 | // 文字强调色(前景色,也决定 ListView 的默认阴影颜色) 63 | accentColor: isDarkMode ? MyColor.white : MyColor.primary, 64 | // Tab 指示器的颜色 65 | // indicatorColor: isDarkMode ? MyColor.primary[50] : MyColor.white, 66 | // 页面背景色 67 | scaffoldBackgroundColor: isDarkMode ? MyColor.dark_bg : MyColor.white, 68 | // 用于突出显示切换 Widget(如 Switch,Radio 和 Checkbox) 69 | toggleableActiveColor: MyColor.primary, 70 | ); 71 | return themeData; 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /lib/utils/device_util.dart: -------------------------------------------------------------------------------- 1 | import 'dart:io'; 2 | import 'package:flutter/foundation.dart'; 3 | 4 | /// https://medium.com/gskinner-team/flutter-simplify-platform-screen-size-detection-4cb6fc4f7ed1 5 | /// 判断设备 6 | class DeviceUtil { 7 | static bool get isDesktop => !isWeb && (isWindows || isLinux || isMacOS); 8 | static bool get isMobile => isAndroid || isIOS; 9 | static bool get isWeb => kIsWeb; 10 | 11 | static bool get isWindows => Platform.isWindows; 12 | static bool get isLinux => Platform.isLinux; 13 | static bool get isMacOS => Platform.isMacOS; 14 | static bool get isAndroid => Platform.isAndroid; 15 | static bool get isFuchsia => Platform.isFuchsia; 16 | static bool get isIOS => Platform.isIOS; 17 | } 18 | -------------------------------------------------------------------------------- /lib/utils/string_util.dart: -------------------------------------------------------------------------------- 1 | /// 字符串工具类 2 | class StringUtil { 3 | // 判断字符串是否不为空 4 | static bool isNotEmpty(String? text) { 5 | return text?.isNotEmpty ?? false; 6 | } 7 | 8 | // 判断字符串是否为空 9 | static bool isEmpty(String? text) { 10 | return text?.isEmpty ?? true; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /lib/widgets/login_input.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | /// 登录输入框 4 | class LoginInput extends StatelessWidget { 5 | // 提示文字 6 | final String hintText; 7 | // 前缀图标 8 | final Widget? prefixIcon; 9 | // 控制器 10 | final TextEditingController controller; 11 | // 最多输入数,有值后右下角就会有一个计数器 12 | final int maxLength; 13 | // 隐藏文本 14 | final bool obscureText; 15 | // 键盘类型 16 | final TextInputType keyboardType; 17 | // 校验规则 18 | final FormFieldValidator? validator; 19 | 20 | const LoginInput( 21 | this.hintText, 22 | this.prefixIcon, 23 | this.controller, { 24 | Key? key, 25 | this.maxLength = 18, 26 | this.obscureText = false, 27 | this.keyboardType = TextInputType.text, 28 | this.validator, 29 | }) : super(key: key); 30 | 31 | @override 32 | Widget build(BuildContext context) { 33 | // Form 的子元素必须是 TextFormField,TextFormField 具备 TextField 的所有属性 34 | return TextFormField( 35 | controller: controller, 36 | maxLength: maxLength, 37 | keyboardType: keyboardType, 38 | obscureText: obscureText, 39 | // decoration 设置输入框的样式 40 | decoration: InputDecoration( 41 | // 隐藏计数器 42 | counterText: '', 43 | hintText: hintText, 44 | prefixIcon: prefixIcon, 45 | // 填充背景色 46 | filled: true, 47 | border: OutlineInputBorder( 48 | // 圆角形 49 | borderRadius: BorderRadius.all( 50 | Radius.circular(32), 51 | ), 52 | // 去除边框 53 | borderSide: BorderSide.none, 54 | ), 55 | // 内容内边距 56 | contentPadding: EdgeInsets.only( 57 | top: 0, 58 | bottom: 0, 59 | ), 60 | ), 61 | // 校验 62 | validator: validator, 63 | ); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /pubspec.lock: -------------------------------------------------------------------------------- 1 | # Generated by pub 2 | # See https://dart.dev/tools/pub/glossary#lockfile 3 | packages: 4 | async: 5 | dependency: transitive 6 | description: 7 | name: async 8 | url: "https://pub.flutter-io.cn" 9 | source: hosted 10 | version: "2.8.2" 11 | boolean_selector: 12 | dependency: transitive 13 | description: 14 | name: boolean_selector 15 | url: "https://pub.flutter-io.cn" 16 | source: hosted 17 | version: "2.1.0" 18 | characters: 19 | dependency: transitive 20 | description: 21 | name: characters 22 | url: "https://pub.flutter-io.cn" 23 | source: hosted 24 | version: "1.2.0" 25 | charcode: 26 | dependency: transitive 27 | description: 28 | name: charcode 29 | url: "https://pub.flutter-io.cn" 30 | source: hosted 31 | version: "1.3.1" 32 | clock: 33 | dependency: transitive 34 | description: 35 | name: clock 36 | url: "https://pub.flutter-io.cn" 37 | source: hosted 38 | version: "1.1.0" 39 | collection: 40 | dependency: transitive 41 | description: 42 | name: collection 43 | url: "https://pub.flutter-io.cn" 44 | source: hosted 45 | version: "1.15.0" 46 | dio: 47 | dependency: "direct main" 48 | description: 49 | name: dio 50 | url: "https://pub.flutter-io.cn" 51 | source: hosted 52 | version: "4.0.5-beta1" 53 | fake_async: 54 | dependency: transitive 55 | description: 56 | name: fake_async 57 | url: "https://pub.flutter-io.cn" 58 | source: hosted 59 | version: "1.2.0" 60 | ffi: 61 | dependency: transitive 62 | description: 63 | name: ffi 64 | url: "https://pub.flutter-io.cn" 65 | source: hosted 66 | version: "1.1.2" 67 | file: 68 | dependency: transitive 69 | description: 70 | name: file 71 | url: "https://pub.flutter-io.cn" 72 | source: hosted 73 | version: "6.1.2" 74 | flutter: 75 | dependency: "direct main" 76 | description: flutter 77 | source: sdk 78 | version: "0.0.0" 79 | flutter_easyloading: 80 | dependency: "direct main" 81 | description: 82 | name: flutter_easyloading 83 | url: "https://pub.flutter-io.cn" 84 | source: hosted 85 | version: "3.0.3" 86 | flutter_localizations: 87 | dependency: "direct main" 88 | description: flutter 89 | source: sdk 90 | version: "0.0.0" 91 | flutter_spinkit: 92 | dependency: transitive 93 | description: 94 | name: flutter_spinkit 95 | url: "https://pub.flutter-io.cn" 96 | source: hosted 97 | version: "5.1.0" 98 | flutter_test: 99 | dependency: "direct dev" 100 | description: flutter 101 | source: sdk 102 | version: "0.0.0" 103 | flutter_web_plugins: 104 | dependency: transitive 105 | description: flutter 106 | source: sdk 107 | version: "0.0.0" 108 | http_parser: 109 | dependency: transitive 110 | description: 111 | name: http_parser 112 | url: "https://pub.flutter-io.cn" 113 | source: hosted 114 | version: "4.0.0" 115 | intl: 116 | dependency: transitive 117 | description: 118 | name: intl 119 | url: "https://pub.flutter-io.cn" 120 | source: hosted 121 | version: "0.17.0" 122 | js: 123 | dependency: transitive 124 | description: 125 | name: js 126 | url: "https://pub.flutter-io.cn" 127 | source: hosted 128 | version: "0.6.3" 129 | matcher: 130 | dependency: transitive 131 | description: 132 | name: matcher 133 | url: "https://pub.flutter-io.cn" 134 | source: hosted 135 | version: "0.12.11" 136 | meta: 137 | dependency: transitive 138 | description: 139 | name: meta 140 | url: "https://pub.flutter-io.cn" 141 | source: hosted 142 | version: "1.7.0" 143 | nested: 144 | dependency: transitive 145 | description: 146 | name: nested 147 | url: "https://pub.flutter-io.cn" 148 | source: hosted 149 | version: "1.0.0" 150 | path: 151 | dependency: transitive 152 | description: 153 | name: path 154 | url: "https://pub.flutter-io.cn" 155 | source: hosted 156 | version: "1.8.0" 157 | path_provider_linux: 158 | dependency: transitive 159 | description: 160 | name: path_provider_linux 161 | url: "https://pub.flutter-io.cn" 162 | source: hosted 163 | version: "2.1.2" 164 | path_provider_platform_interface: 165 | dependency: transitive 166 | description: 167 | name: path_provider_platform_interface 168 | url: "https://pub.flutter-io.cn" 169 | source: hosted 170 | version: "2.0.1" 171 | path_provider_windows: 172 | dependency: transitive 173 | description: 174 | name: path_provider_windows 175 | url: "https://pub.flutter-io.cn" 176 | source: hosted 177 | version: "2.0.4" 178 | platform: 179 | dependency: transitive 180 | description: 181 | name: platform 182 | url: "https://pub.flutter-io.cn" 183 | source: hosted 184 | version: "3.0.2" 185 | plugin_platform_interface: 186 | dependency: transitive 187 | description: 188 | name: plugin_platform_interface 189 | url: "https://pub.flutter-io.cn" 190 | source: hosted 191 | version: "2.0.2" 192 | process: 193 | dependency: transitive 194 | description: 195 | name: process 196 | url: "https://pub.flutter-io.cn" 197 | source: hosted 198 | version: "4.2.4" 199 | provider: 200 | dependency: "direct main" 201 | description: 202 | name: provider 203 | url: "https://pub.flutter-io.cn" 204 | source: hosted 205 | version: "6.0.1" 206 | shared_preferences: 207 | dependency: "direct main" 208 | description: 209 | name: shared_preferences 210 | url: "https://pub.flutter-io.cn" 211 | source: hosted 212 | version: "2.0.11" 213 | shared_preferences_android: 214 | dependency: transitive 215 | description: 216 | name: shared_preferences_android 217 | url: "https://pub.flutter-io.cn" 218 | source: hosted 219 | version: "2.0.9" 220 | shared_preferences_ios: 221 | dependency: transitive 222 | description: 223 | name: shared_preferences_ios 224 | url: "https://pub.flutter-io.cn" 225 | source: hosted 226 | version: "2.0.8" 227 | shared_preferences_linux: 228 | dependency: transitive 229 | description: 230 | name: shared_preferences_linux 231 | url: "https://pub.flutter-io.cn" 232 | source: hosted 233 | version: "2.0.3" 234 | shared_preferences_macos: 235 | dependency: transitive 236 | description: 237 | name: shared_preferences_macos 238 | url: "https://pub.flutter-io.cn" 239 | source: hosted 240 | version: "2.0.2" 241 | shared_preferences_platform_interface: 242 | dependency: transitive 243 | description: 244 | name: shared_preferences_platform_interface 245 | url: "https://pub.flutter-io.cn" 246 | source: hosted 247 | version: "2.0.0" 248 | shared_preferences_web: 249 | dependency: transitive 250 | description: 251 | name: shared_preferences_web 252 | url: "https://pub.flutter-io.cn" 253 | source: hosted 254 | version: "2.0.2" 255 | shared_preferences_windows: 256 | dependency: transitive 257 | description: 258 | name: shared_preferences_windows 259 | url: "https://pub.flutter-io.cn" 260 | source: hosted 261 | version: "2.0.3" 262 | sky_engine: 263 | dependency: transitive 264 | description: flutter 265 | source: sdk 266 | version: "0.0.99" 267 | source_span: 268 | dependency: transitive 269 | description: 270 | name: source_span 271 | url: "https://pub.flutter-io.cn" 272 | source: hosted 273 | version: "1.8.1" 274 | stack_trace: 275 | dependency: transitive 276 | description: 277 | name: stack_trace 278 | url: "https://pub.flutter-io.cn" 279 | source: hosted 280 | version: "1.10.0" 281 | stream_channel: 282 | dependency: transitive 283 | description: 284 | name: stream_channel 285 | url: "https://pub.flutter-io.cn" 286 | source: hosted 287 | version: "2.1.0" 288 | string_scanner: 289 | dependency: transitive 290 | description: 291 | name: string_scanner 292 | url: "https://pub.flutter-io.cn" 293 | source: hosted 294 | version: "1.1.0" 295 | term_glyph: 296 | dependency: transitive 297 | description: 298 | name: term_glyph 299 | url: "https://pub.flutter-io.cn" 300 | source: hosted 301 | version: "1.2.0" 302 | test_api: 303 | dependency: transitive 304 | description: 305 | name: test_api 306 | url: "https://pub.flutter-io.cn" 307 | source: hosted 308 | version: "0.4.3" 309 | typed_data: 310 | dependency: transitive 311 | description: 312 | name: typed_data 313 | url: "https://pub.flutter-io.cn" 314 | source: hosted 315 | version: "1.3.0" 316 | vector_math: 317 | dependency: transitive 318 | description: 319 | name: vector_math 320 | url: "https://pub.flutter-io.cn" 321 | source: hosted 322 | version: "2.1.1" 323 | win32: 324 | dependency: transitive 325 | description: 326 | name: win32 327 | url: "https://pub.flutter-io.cn" 328 | source: hosted 329 | version: "2.3.1" 330 | xdg_directories: 331 | dependency: transitive 332 | description: 333 | name: xdg_directories 334 | url: "https://pub.flutter-io.cn" 335 | source: hosted 336 | version: "0.2.0" 337 | sdks: 338 | dart: ">=2.14.0 <3.0.0" 339 | flutter: ">=2.5.0" 340 | -------------------------------------------------------------------------------- /pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: flutter_template_plus 2 | description: flutter_template_plus 3 | 4 | publish_to: 'none' 5 | 6 | # 版本号 7 | version: 1.0.0+1 8 | 9 | environment: 10 | sdk: ">=2.12.0 <3.0.0" 11 | 12 | dependencies: 13 | flutter: 14 | sdk: flutter 15 | # 本地化 16 | flutter_localizations: 17 | sdk: flutter 18 | # 数据持久化 19 | shared_preferences: ^2.0.11 20 | # http 21 | dio: ^4.0.5-beta1 22 | # loading 遮盖层 23 | flutter_easyloading: ^3.0.3 24 | # 状态管理 25 | provider: ^6.0.1 26 | 27 | dev_dependencies: 28 | flutter_test: 29 | sdk: flutter 30 | 31 | # flutter 相关的配置选项 32 | flutter: 33 | # 默认的 Material Design 字体图标 34 | uses-material-design: true 35 | 36 | # 静态资源 37 | assets: 38 | - assets/images/login/ 39 | 40 | # 自定义字体图标(该脚手架没有用这个,用的是 Flutter 自带的默认 Icons) 41 | # 使用教程 https://book.flutterchina.club/chapter3/img_and_icon.html#_3-3-2-icon 42 | fonts: 43 | - family: iconfont 44 | fonts: 45 | - asset: assets/icons/iconfont.ttf 46 | --------------------------------------------------------------------------------