├── .fvm ├── flutter_sdk └── fvm_config.json ├── .gitignore ├── .metadata ├── README.md ├── analysis_options.yaml ├── android ├── .gitignore ├── app │ ├── build.gradle │ ├── proguard-rules.pro │ └── src │ │ ├── debug │ │ └── AndroidManifest.xml │ │ ├── main │ │ ├── AndroidManifest.xml │ │ ├── kotlin │ │ │ └── com │ │ │ │ └── project │ │ │ │ └── flutter_project │ │ │ │ └── MainActivity.kt │ │ └── res │ │ │ ├── drawable-v21 │ │ │ └── launch_background.xml │ │ │ ├── drawable-xhdpi │ │ │ ├── app_icon.png │ │ │ ├── splash_bottom.png │ │ │ └── splash_top_icon.png │ │ │ ├── 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 └── yixiaolunhui.jks ├── assets ├── images │ ├── guide_one.png │ ├── guide_three.png │ ├── guide_two.png │ ├── image1.webp │ ├── image2.webp │ ├── image3.jpg │ ├── image4.webp │ ├── image5.webp │ ├── image6.webp │ ├── image7.webp │ ├── login_wx.png │ ├── splash_bg.jpg │ ├── tabbar │ │ ├── wode-b-dark.png │ │ ├── wode-b-dark.webp │ │ ├── wode-b.png │ │ ├── wode-b.webp │ │ ├── wode-c-dark.png │ │ ├── wode-c-dark.webp │ │ ├── wode-c.png │ │ ├── wode-c.webp │ │ ├── xiaoxi-b-dark.png │ │ ├── xiaoxi-b-dark.webp │ │ ├── xiaoxi-b.png │ │ ├── xiaoxi-b.webp │ │ ├── xiaoxi-c-dark.png │ │ ├── xiaoxi-c-dark.webp │ │ ├── xiaoxi-c.png │ │ ├── xiaoxi-c.webp │ │ ├── youle-dark.png │ │ ├── youle-dark.webp │ │ ├── youle.png │ │ ├── youle.webp │ │ ├── zhiwei-dark.png │ │ ├── zhiwei-dark.webp │ │ ├── zhiwei.png │ │ └── zhiwei.webp │ └── work_top_bg.jpg └── lottie │ └── tab │ ├── niuren-dark.json │ ├── niuren.json │ ├── sousuo-dark.json │ ├── sousuo.json │ ├── wode-b-dark.json │ ├── wode-b.json │ ├── wode-c-dark.json │ ├── wode-c.json │ ├── xiaoxi-b-dark.json │ ├── xiaoxi-b.json │ ├── xiaoxi-c-dark.json │ ├── xiaoxi-c.json │ ├── youle-dark.json │ ├── youle.json │ ├── zhibo-dark.json │ ├── zhibo.json │ ├── zhiwei-dark.json │ └── zhiwei.json ├── imgs ├── guide.gif └── welcome.gif ├── ios ├── .gitignore ├── Flutter │ ├── AppFrameworkInfo.plist │ ├── Debug.xcconfig │ └── Release.xcconfig ├── Podfile ├── 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 ├── core │ ├── app │ │ ├── app.dart │ │ ├── app_life_cycle.dart │ │ └── injection.dart │ ├── base │ │ ├── arguments.dart │ │ ├── navigation_history_observer.dart │ │ └── page_state.dart │ ├── error │ │ └── flutter_error.dart │ └── http │ │ ├── http_api.dart │ │ ├── http_exception.dart │ │ ├── http_request.dart │ │ └── http_url.dart ├── main_beta.dart ├── main_mp.dart ├── main_qa.dart ├── model │ ├── language.dart │ └── work_model.dart ├── page │ ├── code │ │ ├── binding.dart │ │ ├── logic.dart │ │ ├── state.dart │ │ └── view.dart │ ├── guide │ │ ├── logic.dart │ │ ├── state.dart │ │ └── view.dart │ ├── home │ │ ├── binding.dart │ │ ├── child │ │ │ ├── message │ │ │ │ ├── logic.dart │ │ │ │ ├── state.dart │ │ │ │ └── view.dart │ │ │ ├── mine │ │ │ │ ├── logic.dart │ │ │ │ ├── state.dart │ │ │ │ └── view.dart │ │ │ ├── work │ │ │ │ ├── logic.dart │ │ │ │ ├── state.dart │ │ │ │ ├── view.dart │ │ │ │ ├── widget │ │ │ │ │ └── work_list_widget.dart │ │ │ │ └── work_test_data_helper.dart │ │ │ └── youle │ │ │ │ ├── logic.dart │ │ │ │ ├── state.dart │ │ │ │ └── view.dart │ │ ├── logic.dart │ │ ├── state.dart │ │ └── view.dart │ ├── login │ │ ├── binding.dart │ │ ├── logic.dart │ │ ├── state.dart │ │ └── view.dart │ ├── page_ext.dart │ ├── splash │ │ ├── binding.dart │ │ ├── logic.dart │ │ ├── state.dart │ │ └── view.dart │ └── welcome │ │ ├── logic.dart │ │ ├── state.dart │ │ └── view.dart ├── res │ ├── colors │ │ └── color_res.dart │ ├── images │ │ └── r.dart │ └── intl │ │ ├── string_res.dart │ │ ├── string_res_key.dart │ │ └── strings │ │ ├── en_uk_res.dart │ │ ├── en_us_res.dart │ │ ├── ja_jp_res.dart │ │ └── zh_cn_res.dart ├── router │ └── routers.dart ├── util │ ├── date_util.dart │ ├── device_util.dart │ ├── directory_util.dart │ ├── encrypt_util.dart │ ├── image_util.dart │ ├── json_util.dart │ ├── keyboard_util.dart │ ├── locale_util.dart │ ├── log_util.dart │ ├── logger_util.dart │ ├── num_util.dart │ ├── regex_util.dart │ ├── screen_util.dart │ ├── sp_key.dart │ ├── sp_util.dart │ ├── text_util.dart │ ├── timeline_util.dart │ ├── timer_util.dart │ ├── toast_util.dart │ ├── user_util.dart │ └── widget_util.dart └── widgets │ ├── bottom_bar_item.dart │ ├── lottie_bottom_bar_item.dart │ ├── my_app_bar.dart │ └── scale_tabbar.dart ├── linux ├── .gitignore ├── CMakeLists.txt ├── flutter │ ├── CMakeLists.txt │ ├── generated_plugin_registrant.cc │ ├── generated_plugin_registrant.h │ └── generated_plugins.cmake ├── main.cc ├── my_application.cc └── my_application.h ├── macos ├── .gitignore ├── Flutter │ ├── Flutter-Debug.xcconfig │ ├── Flutter-Release.xcconfig │ └── GeneratedPluginRegistrant.swift ├── Podfile ├── Runner.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ └── xcshareddata │ │ │ └── IDEWorkspaceChecks.plist │ └── xcshareddata │ │ └── xcschemes │ │ └── Runner.xcscheme ├── Runner.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ └── IDEWorkspaceChecks.plist └── Runner │ ├── AppDelegate.swift │ ├── Assets.xcassets │ └── AppIcon.appiconset │ │ ├── Contents.json │ │ ├── app_icon_1024.png │ │ ├── app_icon_128.png │ │ ├── app_icon_16.png │ │ ├── app_icon_256.png │ │ ├── app_icon_32.png │ │ ├── app_icon_512.png │ │ └── app_icon_64.png │ ├── Base.lproj │ └── MainMenu.xib │ ├── Configs │ ├── AppInfo.xcconfig │ ├── Debug.xcconfig │ ├── Release.xcconfig │ └── Warnings.xcconfig │ ├── DebugProfile.entitlements │ ├── Info.plist │ ├── MainFlutterWindow.swift │ └── Release.entitlements ├── pubspec.lock ├── pubspec.yaml ├── res_build.sh ├── test └── widget_test.dart ├── web ├── favicon.png ├── icons │ ├── Icon-192.png │ ├── Icon-512.png │ ├── Icon-maskable-192.png │ └── Icon-maskable-512.png ├── index.html └── manifest.json └── windows ├── .gitignore ├── CMakeLists.txt ├── flutter ├── CMakeLists.txt ├── generated_plugin_registrant.cc ├── generated_plugin_registrant.h └── generated_plugins.cmake └── runner ├── CMakeLists.txt ├── Runner.rc ├── flutter_window.cpp ├── flutter_window.h ├── main.cpp ├── resource.h ├── resources └── app_icon.ico ├── runner.exe.manifest ├── utils.cpp ├── utils.h ├── win32_window.cpp └── win32_window.h /.fvm/flutter_sdk: -------------------------------------------------------------------------------- 1 | /Users/zhouweilong/fvm/versions/3.19.3 -------------------------------------------------------------------------------- /.fvm/fvm_config.json: -------------------------------------------------------------------------------- 1 | { 2 | "flutterSdkVersion": "3.19.3", 3 | "flavors": {} 4 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | *.class 3 | *.log 4 | *.pyc 5 | *.swp 6 | .DS_Store 7 | .atom/ 8 | .buildlog/ 9 | .history 10 | .svn/ 11 | migrate_working_dir/ 12 | 13 | # IntelliJ related 14 | *.iml 15 | *.ipr 16 | *.iws 17 | .idea/ 18 | 19 | # The .vscode folder contains launch configuration and tasks you configure in 20 | # VS Code which you may wish to be included in version control, so this line 21 | # is commented out by default. 22 | #.vscode/ 23 | 24 | # Flutter/Dart/Pub related 25 | **/doc/api/ 26 | **/ios/Flutter/.last_build_id 27 | .dart_tool/ 28 | .flutter-plugins 29 | .flutter-plugins-dependencies 30 | .packages 31 | .pub-cache/ 32 | .pub/ 33 | /build/ 34 | 35 | # Symbolication related 36 | app.*.symbols 37 | 38 | # Obfuscation related 39 | app.*.map.json 40 | 41 | # Android Studio will place build artifacts here 42 | /android/app/debug 43 | /android/app/profile 44 | /android/app/release 45 | 46 | # FVM Version Cache 47 | .fvm/ -------------------------------------------------------------------------------- /.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. 5 | 6 | version: 7 | revision: b06b8b2710955028a6b562f5aa6fe62941d6febf 8 | channel: stable 9 | 10 | project_type: app 11 | 12 | # Tracks metadata for the flutter migrate command 13 | migration: 14 | platforms: 15 | - platform: root 16 | create_revision: b06b8b2710955028a6b562f5aa6fe62941d6febf 17 | base_revision: b06b8b2710955028a6b562f5aa6fe62941d6febf 18 | - platform: android 19 | create_revision: b06b8b2710955028a6b562f5aa6fe62941d6febf 20 | base_revision: b06b8b2710955028a6b562f5aa6fe62941d6febf 21 | - platform: ios 22 | create_revision: b06b8b2710955028a6b562f5aa6fe62941d6febf 23 | base_revision: b06b8b2710955028a6b562f5aa6fe62941d6febf 24 | - platform: linux 25 | create_revision: b06b8b2710955028a6b562f5aa6fe62941d6febf 26 | base_revision: b06b8b2710955028a6b562f5aa6fe62941d6febf 27 | - platform: macos 28 | create_revision: b06b8b2710955028a6b562f5aa6fe62941d6febf 29 | base_revision: b06b8b2710955028a6b562f5aa6fe62941d6febf 30 | - platform: web 31 | create_revision: b06b8b2710955028a6b562f5aa6fe62941d6febf 32 | base_revision: b06b8b2710955028a6b562f5aa6fe62941d6febf 33 | - platform: windows 34 | create_revision: b06b8b2710955028a6b562f5aa6fe62941d6febf 35 | base_revision: b06b8b2710955028a6b562f5aa6fe62941d6febf 36 | 37 | # User provided section 38 | 39 | # List of Local paths (relative to this file) that should be 40 | # ignored by the migrate tool. 41 | # 42 | # Files that are not part of the templates will be ignored by default. 43 | unmanaged_files: 44 | - 'lib/main.dart' 45 | - 'ios/Runner.xcodeproj/project.pbxproj' 46 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## 仿Boss项目 2 | 3 | 此项目是使用Flutter语言仿Boss的项目,用于学习Flutter的记录。 4 | 5 | ## 效果界面 6 | 7 | | 界面名称 | 效果 | 8 | |:------|:------------------------------------------------------------------------------------------------------------------:| 9 | | 欢迎页 | 欢迎页 | 10 | | 引导页 | 引导页 | 11 | | 登录页 | 登录页 | 12 | | 验证码 | 验证码 | 13 | | Tab切换 | Tab切换 | 14 | | 首页列表 | 首页列表 | -------------------------------------------------------------------------------- /analysis_options.yaml: -------------------------------------------------------------------------------- 1 | # This file configures the analyzer, which statically analyzes Dart code to 2 | # check for errors, warnings, and lints. 3 | # 4 | # The issues identified by the analyzer are surfaced in the UI of Dart-enabled 5 | # IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be 6 | # invoked from the command line by running `flutter analyze`. 7 | 8 | # The following line activates a set of recommended lints for Flutter apps, 9 | # packages, and plugins designed to encourage good coding practices. 10 | include: package:flutter_lints/flutter.yaml 11 | 12 | linter: 13 | # The lint rules applied to this project can be customized in the 14 | # section below to disable rules from the `package:flutter_lints/flutter.yaml` 15 | # included above or to enable additional rules. A list of all available lints 16 | # and their documentation is published at 17 | # https://dart-lang.github.io/linter/lints/index.html. 18 | # 19 | # Instead of disabling a lint rule for the entire project in the 20 | # section below, it can also be suppressed for a single line of code 21 | # or a specific dart file by using the `// ignore: name_of_lint` and 22 | # `// ignore_for_file: name_of_lint` syntax on the line or in the file 23 | # producing the lint. 24 | rules: 25 | # avoid_print: false # Uncomment to disable the `avoid_print` rule 26 | # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule 27 | 28 | # Additional information about this file can be found at 29 | # https://dart.dev/guides/language/analysis-options 30 | -------------------------------------------------------------------------------- /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 -> localProperties.load(reader) 5 | } 6 | } 7 | 8 | def flutterRoot = localProperties.getProperty('flutter.sdk') 9 | if (flutterRoot == null) { 10 | throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") 11 | } 12 | 13 | def flutterVersionCode = localProperties.getProperty('flutter.versionCode') 14 | if (flutterVersionCode == null) { 15 | flutterVersionCode = '1' 16 | } 17 | 18 | def flutterVersionName = localProperties.getProperty('flutter.versionName') 19 | if (flutterVersionName == null) { 20 | flutterVersionName = '1.0' 21 | } 22 | 23 | apply plugin: 'com.android.application' 24 | apply plugin: 'kotlin-android' 25 | apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" 26 | 27 | android { 28 | compileSdkVersion flutter.compileSdkVersion 29 | ndkVersion flutter.ndkVersion 30 | 31 | compileOptions { 32 | sourceCompatibility JavaVersion.VERSION_1_8 33 | targetCompatibility JavaVersion.VERSION_1_8 34 | } 35 | 36 | signingConfigs { 37 | debug { 38 | storeFile file('../yixiaolunhui.jks') 39 | storePassword 'yixiaolunhui' 40 | keyPassword 'yixiaolunhui' 41 | keyAlias 'yixiaolunhui' 42 | } 43 | 44 | release { 45 | storeFile file('../yixiaolunhui.jks') 46 | storePassword 'yixiaolunhui' 47 | keyPassword 'yixiaolunhui' 48 | keyAlias 'yixiaolunhui' 49 | } 50 | } 51 | 52 | kotlinOptions { 53 | jvmTarget = '1.8' 54 | } 55 | 56 | sourceSets { 57 | main.java.srcDirs += 'src/main/kotlin' 58 | } 59 | 60 | defaultConfig { 61 | applicationId "com.project.flutter_project" 62 | minSdkVersion 21 63 | targetSdkVersion flutter.targetSdkVersion 64 | versionCode flutterVersionCode.toInteger() 65 | versionName flutterVersionName 66 | } 67 | 68 | lintOptions { 69 | checkReleaseBuilds false 70 | } 71 | 72 | flavorDimensions "FlutterDemo" 73 | productFlavors { 74 | qa { 75 | dimension "FlutterDemo" 76 | } 77 | 78 | beta { 79 | dimension "FlutterDemo" 80 | } 81 | 82 | mp { 83 | dimension "FlutterDemo" 84 | } 85 | } 86 | 87 | buildTypes { 88 | 89 | debug { 90 | signingConfig signingConfigs.debug 91 | } 92 | 93 | release { 94 | signingConfig signingConfigs.release 95 | minifyEnabled true 96 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 97 | } 98 | } 99 | 100 | applicationVariants.all { variant -> 101 | variant.outputs.all { 102 | def version = variant.versionName // 版本号 103 | def buildType = variant.buildType.name // 包类型,debug 还是 release 104 | def flavors = variant.productFlavors.name 105 | def createTime = new Date().format('yyyyMMddHHmm') // 打包时间 202109251645 106 | def fileName = "App_${version}_${buildType}_qa_${createTime}.apk" 107 | if (flavors.contains("mp")) { 108 | fileName = "App_${version}_${buildType}_mp_${createTime}.apk" 109 | } else if (flavors.contains("beta")) { 110 | fileName = "App_${version}_${buildType}_beta_${createTime}.apk" 111 | } else if (flavors.contains("qa")) { 112 | fileName = "App_${version}_${buildType}_qa_${createTime}.apk" 113 | } else { 114 | fileName = "App_${version}_${buildType}_qa_${createTime}.apk" 115 | } 116 | outputFileName = fileName 117 | } 118 | } 119 | } 120 | 121 | flutter { 122 | source '../..' 123 | } 124 | 125 | dependencies { 126 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" 127 | } 128 | -------------------------------------------------------------------------------- /android/app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | -keep class io.flutter.app.** { *; } 2 | -keep class io.flutter.plugin.** { *; } 3 | -keep class io.flutter.util.** { *; } 4 | -keep class io.flutter.view.** { *; } 5 | -keep class io.flutter.** { *; } 6 | -keep class io.flutter.plugins.** { *; } 7 | -------------------------------------------------------------------------------- /android/app/src/debug/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | 10 | 19 | 22 | 23 | 24 | 25 | 26 | 27 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /android/app/src/main/kotlin/com/project/flutter_project/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.project.flutter_project 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 | 8 | 9 | 10 | 13 | 14 | 17 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable-xhdpi/app_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yixiaolunhui/flutter_project/788a64a93395b3fb32aad400b87785f252a8c71b/android/app/src/main/res/drawable-xhdpi/app_icon.png -------------------------------------------------------------------------------- /android/app/src/main/res/drawable-xhdpi/splash_bottom.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yixiaolunhui/flutter_project/788a64a93395b3fb32aad400b87785f252a8c71b/android/app/src/main/res/drawable-xhdpi/splash_bottom.png -------------------------------------------------------------------------------- /android/app/src/main/res/drawable-xhdpi/splash_top_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yixiaolunhui/flutter_project/788a64a93395b3fb32aad400b87785f252a8c71b/android/app/src/main/res/drawable-xhdpi/splash_top_icon.png -------------------------------------------------------------------------------- /android/app/src/main/res/drawable/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 13 | 14 | 17 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yixiaolunhui/flutter_project/788a64a93395b3fb32aad400b87785f252a8c71b/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yixiaolunhui/flutter_project/788a64a93395b3fb32aad400b87785f252a8c71b/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yixiaolunhui/flutter_project/788a64a93395b3fb32aad400b87785f252a8c71b/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yixiaolunhui/flutter_project/788a64a93395b3fb32aad400b87785f252a8c71b/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yixiaolunhui/flutter_project/788a64a93395b3fb32aad400b87785f252a8c71b/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/values-night/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 16 | 20 | 21 | -------------------------------------------------------------------------------- /android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 14 | 18 | 19 | -------------------------------------------------------------------------------- /android/app/src/profile/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /android/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | ext.kotlin_version = '1.7.10' 3 | repositories { 4 | google() 5 | mavenCentral() 6 | } 7 | 8 | dependencies { 9 | classpath 'com.android.tools.build:gradle:7.2.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 | } 25 | subprojects { 26 | project.evaluationDependsOn(':app') 27 | } 28 | 29 | tasks.register("clean", Delete) { 30 | delete rootProject.buildDir 31 | } 32 | -------------------------------------------------------------------------------- /android/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx1536M 2 | android.useAndroidX=true 3 | android.enableJetifier=true 4 | -------------------------------------------------------------------------------- /android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | zipStoreBase=GRADLE_USER_HOME 4 | zipStorePath=wrapper/dists 5 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip 6 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /android/yixiaolunhui.jks: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yixiaolunhui/flutter_project/788a64a93395b3fb32aad400b87785f252a8c71b/android/yixiaolunhui.jks -------------------------------------------------------------------------------- /assets/images/guide_one.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yixiaolunhui/flutter_project/788a64a93395b3fb32aad400b87785f252a8c71b/assets/images/guide_one.png -------------------------------------------------------------------------------- /assets/images/guide_three.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yixiaolunhui/flutter_project/788a64a93395b3fb32aad400b87785f252a8c71b/assets/images/guide_three.png -------------------------------------------------------------------------------- /assets/images/guide_two.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yixiaolunhui/flutter_project/788a64a93395b3fb32aad400b87785f252a8c71b/assets/images/guide_two.png -------------------------------------------------------------------------------- /assets/images/image1.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yixiaolunhui/flutter_project/788a64a93395b3fb32aad400b87785f252a8c71b/assets/images/image1.webp -------------------------------------------------------------------------------- /assets/images/image2.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yixiaolunhui/flutter_project/788a64a93395b3fb32aad400b87785f252a8c71b/assets/images/image2.webp -------------------------------------------------------------------------------- /assets/images/image3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yixiaolunhui/flutter_project/788a64a93395b3fb32aad400b87785f252a8c71b/assets/images/image3.jpg -------------------------------------------------------------------------------- /assets/images/image4.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yixiaolunhui/flutter_project/788a64a93395b3fb32aad400b87785f252a8c71b/assets/images/image4.webp -------------------------------------------------------------------------------- /assets/images/image5.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yixiaolunhui/flutter_project/788a64a93395b3fb32aad400b87785f252a8c71b/assets/images/image5.webp -------------------------------------------------------------------------------- /assets/images/image6.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yixiaolunhui/flutter_project/788a64a93395b3fb32aad400b87785f252a8c71b/assets/images/image6.webp -------------------------------------------------------------------------------- /assets/images/image7.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yixiaolunhui/flutter_project/788a64a93395b3fb32aad400b87785f252a8c71b/assets/images/image7.webp -------------------------------------------------------------------------------- /assets/images/login_wx.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yixiaolunhui/flutter_project/788a64a93395b3fb32aad400b87785f252a8c71b/assets/images/login_wx.png -------------------------------------------------------------------------------- /assets/images/splash_bg.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yixiaolunhui/flutter_project/788a64a93395b3fb32aad400b87785f252a8c71b/assets/images/splash_bg.jpg -------------------------------------------------------------------------------- /assets/images/tabbar/wode-b-dark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yixiaolunhui/flutter_project/788a64a93395b3fb32aad400b87785f252a8c71b/assets/images/tabbar/wode-b-dark.png -------------------------------------------------------------------------------- /assets/images/tabbar/wode-b-dark.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yixiaolunhui/flutter_project/788a64a93395b3fb32aad400b87785f252a8c71b/assets/images/tabbar/wode-b-dark.webp -------------------------------------------------------------------------------- /assets/images/tabbar/wode-b.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yixiaolunhui/flutter_project/788a64a93395b3fb32aad400b87785f252a8c71b/assets/images/tabbar/wode-b.png -------------------------------------------------------------------------------- /assets/images/tabbar/wode-b.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yixiaolunhui/flutter_project/788a64a93395b3fb32aad400b87785f252a8c71b/assets/images/tabbar/wode-b.webp -------------------------------------------------------------------------------- /assets/images/tabbar/wode-c-dark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yixiaolunhui/flutter_project/788a64a93395b3fb32aad400b87785f252a8c71b/assets/images/tabbar/wode-c-dark.png -------------------------------------------------------------------------------- /assets/images/tabbar/wode-c-dark.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yixiaolunhui/flutter_project/788a64a93395b3fb32aad400b87785f252a8c71b/assets/images/tabbar/wode-c-dark.webp -------------------------------------------------------------------------------- /assets/images/tabbar/wode-c.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yixiaolunhui/flutter_project/788a64a93395b3fb32aad400b87785f252a8c71b/assets/images/tabbar/wode-c.png -------------------------------------------------------------------------------- /assets/images/tabbar/wode-c.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yixiaolunhui/flutter_project/788a64a93395b3fb32aad400b87785f252a8c71b/assets/images/tabbar/wode-c.webp -------------------------------------------------------------------------------- /assets/images/tabbar/xiaoxi-b-dark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yixiaolunhui/flutter_project/788a64a93395b3fb32aad400b87785f252a8c71b/assets/images/tabbar/xiaoxi-b-dark.png -------------------------------------------------------------------------------- /assets/images/tabbar/xiaoxi-b-dark.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yixiaolunhui/flutter_project/788a64a93395b3fb32aad400b87785f252a8c71b/assets/images/tabbar/xiaoxi-b-dark.webp -------------------------------------------------------------------------------- /assets/images/tabbar/xiaoxi-b.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yixiaolunhui/flutter_project/788a64a93395b3fb32aad400b87785f252a8c71b/assets/images/tabbar/xiaoxi-b.png -------------------------------------------------------------------------------- /assets/images/tabbar/xiaoxi-b.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yixiaolunhui/flutter_project/788a64a93395b3fb32aad400b87785f252a8c71b/assets/images/tabbar/xiaoxi-b.webp -------------------------------------------------------------------------------- /assets/images/tabbar/xiaoxi-c-dark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yixiaolunhui/flutter_project/788a64a93395b3fb32aad400b87785f252a8c71b/assets/images/tabbar/xiaoxi-c-dark.png -------------------------------------------------------------------------------- /assets/images/tabbar/xiaoxi-c-dark.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yixiaolunhui/flutter_project/788a64a93395b3fb32aad400b87785f252a8c71b/assets/images/tabbar/xiaoxi-c-dark.webp -------------------------------------------------------------------------------- /assets/images/tabbar/xiaoxi-c.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yixiaolunhui/flutter_project/788a64a93395b3fb32aad400b87785f252a8c71b/assets/images/tabbar/xiaoxi-c.png -------------------------------------------------------------------------------- /assets/images/tabbar/xiaoxi-c.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yixiaolunhui/flutter_project/788a64a93395b3fb32aad400b87785f252a8c71b/assets/images/tabbar/xiaoxi-c.webp -------------------------------------------------------------------------------- /assets/images/tabbar/youle-dark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yixiaolunhui/flutter_project/788a64a93395b3fb32aad400b87785f252a8c71b/assets/images/tabbar/youle-dark.png -------------------------------------------------------------------------------- /assets/images/tabbar/youle-dark.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yixiaolunhui/flutter_project/788a64a93395b3fb32aad400b87785f252a8c71b/assets/images/tabbar/youle-dark.webp -------------------------------------------------------------------------------- /assets/images/tabbar/youle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yixiaolunhui/flutter_project/788a64a93395b3fb32aad400b87785f252a8c71b/assets/images/tabbar/youle.png -------------------------------------------------------------------------------- /assets/images/tabbar/youle.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yixiaolunhui/flutter_project/788a64a93395b3fb32aad400b87785f252a8c71b/assets/images/tabbar/youle.webp -------------------------------------------------------------------------------- /assets/images/tabbar/zhiwei-dark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yixiaolunhui/flutter_project/788a64a93395b3fb32aad400b87785f252a8c71b/assets/images/tabbar/zhiwei-dark.png -------------------------------------------------------------------------------- /assets/images/tabbar/zhiwei-dark.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yixiaolunhui/flutter_project/788a64a93395b3fb32aad400b87785f252a8c71b/assets/images/tabbar/zhiwei-dark.webp -------------------------------------------------------------------------------- /assets/images/tabbar/zhiwei.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yixiaolunhui/flutter_project/788a64a93395b3fb32aad400b87785f252a8c71b/assets/images/tabbar/zhiwei.png -------------------------------------------------------------------------------- /assets/images/tabbar/zhiwei.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yixiaolunhui/flutter_project/788a64a93395b3fb32aad400b87785f252a8c71b/assets/images/tabbar/zhiwei.webp -------------------------------------------------------------------------------- /assets/images/work_top_bg.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yixiaolunhui/flutter_project/788a64a93395b3fb32aad400b87785f252a8c71b/assets/images/work_top_bg.jpg -------------------------------------------------------------------------------- /imgs/guide.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yixiaolunhui/flutter_project/788a64a93395b3fb32aad400b87785f252a8c71b/imgs/guide.gif -------------------------------------------------------------------------------- /imgs/welcome.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yixiaolunhui/flutter_project/788a64a93395b3fb32aad400b87785f252a8c71b/imgs/welcome.gif -------------------------------------------------------------------------------- /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 | 11.0 25 | 26 | 27 | -------------------------------------------------------------------------------- /ios/Flutter/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" 2 | #include "Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /ios/Flutter/Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" 2 | #include "Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /ios/Podfile: -------------------------------------------------------------------------------- 1 | # Uncomment this line to define a global platform for your project 2 | # platform :ios, '12.0' 3 | 4 | # CocoaPods analytics sends network stats synchronously affecting flutter build latency. 5 | ENV['COCOAPODS_DISABLE_STATS'] = 'true' 6 | 7 | project 'Runner', { 8 | 'Debug' => :debug, 9 | 'Profile' => :release, 10 | 'Release' => :release, 11 | } 12 | 13 | def flutter_root 14 | generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__) 15 | unless File.exist?(generated_xcode_build_settings_path) 16 | raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first" 17 | end 18 | 19 | File.foreach(generated_xcode_build_settings_path) do |line| 20 | matches = line.match(/FLUTTER_ROOT\=(.*)/) 21 | return matches[1].strip if matches 22 | end 23 | raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get" 24 | end 25 | 26 | require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) 27 | 28 | flutter_ios_podfile_setup 29 | 30 | target 'Runner' do 31 | use_frameworks! 32 | use_modular_headers! 33 | 34 | flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__)) 35 | target 'RunnerTests' do 36 | inherit! :search_paths 37 | end 38 | end 39 | 40 | post_install do |installer| 41 | installer.pods_project.targets.each do |target| 42 | flutter_additional_ios_build_settings(target) 43 | end 44 | end 45 | -------------------------------------------------------------------------------- /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 | 37 | 38 | 39 | 40 | 41 | 42 | 52 | 54 | 60 | 61 | 62 | 63 | 69 | 71 | 77 | 78 | 79 | 80 | 82 | 83 | 86 | 87 | 88 | -------------------------------------------------------------------------------- /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/yixiaolunhui/flutter_project/788a64a93395b3fb32aad400b87785f252a8c71b/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/yixiaolunhui/flutter_project/788a64a93395b3fb32aad400b87785f252a8c71b/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/yixiaolunhui/flutter_project/788a64a93395b3fb32aad400b87785f252a8c71b/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/yixiaolunhui/flutter_project/788a64a93395b3fb32aad400b87785f252a8c71b/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/yixiaolunhui/flutter_project/788a64a93395b3fb32aad400b87785f252a8c71b/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/yixiaolunhui/flutter_project/788a64a93395b3fb32aad400b87785f252a8c71b/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/yixiaolunhui/flutter_project/788a64a93395b3fb32aad400b87785f252a8c71b/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/yixiaolunhui/flutter_project/788a64a93395b3fb32aad400b87785f252a8c71b/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/yixiaolunhui/flutter_project/788a64a93395b3fb32aad400b87785f252a8c71b/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/yixiaolunhui/flutter_project/788a64a93395b3fb32aad400b87785f252a8c71b/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/yixiaolunhui/flutter_project/788a64a93395b3fb32aad400b87785f252a8c71b/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/yixiaolunhui/flutter_project/788a64a93395b3fb32aad400b87785f252a8c71b/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/yixiaolunhui/flutter_project/788a64a93395b3fb32aad400b87785f252a8c71b/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/yixiaolunhui/flutter_project/788a64a93395b3fb32aad400b87785f252a8c71b/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/yixiaolunhui/flutter_project/788a64a93395b3fb32aad400b87785f252a8c71b/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/yixiaolunhui/flutter_project/788a64a93395b3fb32aad400b87785f252a8c71b/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yixiaolunhui/flutter_project/788a64a93395b3fb32aad400b87785f252a8c71b/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yixiaolunhui/flutter_project/788a64a93395b3fb32aad400b87785f252a8c71b/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 | CFBundleDisplayName 8 | Flutter Project 9 | CFBundleExecutable 10 | $(EXECUTABLE_NAME) 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | flutter_project 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | $(FLUTTER_BUILD_NAME) 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | $(FLUTTER_BUILD_NUMBER) 25 | LSRequiresIPhoneOS 26 | 27 | UILaunchStoryboardName 28 | LaunchScreen 29 | UIMainStoryboardFile 30 | Main 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | UIViewControllerBasedStatusBarAppearance 45 | 46 | CADisableMinimumFrameDurationOnPhone 47 | 48 | UIApplicationSupportsIndirectInputEvents 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /ios/Runner/Runner-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | #import "GeneratedPluginRegistrant.h" 2 | -------------------------------------------------------------------------------- /lib/core/app/app.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_project/core/app/injection.dart'; 3 | import 'package:flutter_project/core/base/arguments.dart'; 4 | import 'package:flutter_project/core/base/navigation_history_observer.dart'; 5 | import 'package:flutter_project/page/splash/binding.dart'; 6 | import 'package:flutter_project/page/splash/view.dart'; 7 | import 'package:flutter_project/res/intl/string_res.dart'; 8 | import 'package:flutter_project/router/routers.dart'; 9 | import 'package:flutter_project/util/keyboard_util.dart'; 10 | import 'package:flutter_project/util/locale_util.dart'; 11 | import 'package:get/get.dart'; 12 | 13 | /// 环境类型 14 | enum Env { qa, beta, mp } 15 | 16 | /// 当前环境类型 17 | Env appEnv = Env.qa; 18 | 19 | /// 是否需要调试工具 20 | bool get isNeedUme { 21 | return appEnv == Env.qa || appEnv == Env.beta; 22 | } 23 | 24 | /// 初始化 25 | Future initApp(Env env) async { 26 | appEnv = env; 27 | await Injection.init(); 28 | runApp(_myApp()); 29 | } 30 | 31 | Widget _myApp() { 32 | return GetMaterialApp( 33 | getPages: Routers.routePages, 34 | initialRoute: '/', 35 | debugShowCheckedModeBanner: false, 36 | builder: (context, child) => MediaQuery( 37 | data: MediaQuery.of(context).copyWith(textScaleFactor: 1.0), 38 | child: Scaffold( 39 | body: GestureDetector( 40 | onTap: () { 41 | //全局控制-点击空白区域关闭键盘 42 | KeyboardUtils.hideKeyboard(context); 43 | }, 44 | child: child, 45 | ), 46 | )), 47 | navigatorObservers: [NavigationHistoryObserver()], 48 | onGenerateRoute: (settings) { 49 | var uri = Uri.parse(settings.name ?? ""); 50 | var route = uri.path; 51 | var params = uri.queryParameters; 52 | final routePage = Routers.routePages.firstWhereOrNull( 53 | (routePage) => routePage.name == route, 54 | ); 55 | if (routePage == null) { 56 | return null; 57 | } 58 | return MaterialPageRoute( 59 | builder: (context) { 60 | var widget = routePage.page.call(); 61 | if (widget is RouteQueryMixin) { 62 | (widget as RouteQueryMixin).routeParams.addAll(params); 63 | } 64 | if (widget is ArgumentsMixin) { 65 | (widget as ArgumentsMixin).arguments = settings.arguments; 66 | } 67 | return widget; 68 | }, 69 | settings: settings, 70 | ); 71 | }, 72 | 73 | //主题颜色 74 | themeMode: ThemeMode.system, 75 | // theme: ThemeUtil.lightTheme, 76 | // darkTheme: ThemeUtil.darkTheme, 77 | 78 | //国际化支持-来源配置 79 | translations: StringRes(), 80 | 81 | //国际化支持-默认语言 82 | locale: LocaleOptions.getDefault(), 83 | 84 | //国际化支持-备用语言 85 | fallbackLocale: const Locale('en', 'US'), 86 | 87 | //默认路由跳转动画 88 | defaultTransition: Transition.native, 89 | 90 | //初始化启动页的page和binding 91 | initialBinding: SplashBinding(), 92 | 93 | home: const SplashPage(), 94 | ); 95 | } 96 | -------------------------------------------------------------------------------- /lib/core/app/app_life_cycle.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter/widgets.dart'; 3 | import 'package:flutter_project/util/logger_util.dart'; 4 | import 'package:get/get.dart'; 5 | 6 | /// 用于监听系统暗黑模式改变 7 | class AppLifeCycleDelegate with WidgetsBindingObserver { 8 | static final AppLifeCycleDelegate _appLifeCycleDelegate = 9 | AppLifeCycleDelegate._init(); 10 | 11 | AppLifeCycleDelegate._init() { 12 | WidgetsBinding.instance.addObserver(this); 13 | } 14 | 15 | factory AppLifeCycleDelegate() { 16 | return _appLifeCycleDelegate; 17 | } 18 | 19 | @override 20 | void didChangePlatformBrightness() { 21 | super.didChangePlatformBrightness(); 22 | Log().d("手机系统暗黑模式改变"); 23 | Get.forceAppUpdate(); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /lib/core/app/injection.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_project/core/app/app_life_cycle.dart'; 2 | import 'package:flutter_project/core/base/page_state.dart'; 3 | import 'package:flutter_project/core/error/flutter_error.dart'; 4 | import 'package:flutter_project/util/logger_util.dart'; 5 | import 'package:flutter_project/util/screen_util.dart'; 6 | import 'package:get/get.dart'; 7 | import 'package:shared_preferences/shared_preferences.dart'; 8 | 9 | /// 初始化时进行依赖注入-全局 10 | class Injection { 11 | ///初始化 12 | static Future init() async { 13 | await Get.putAsync(() => SharedPreferences.getInstance()); 14 | //异常处理 15 | ErrorHelper.init(); 16 | //路由记录监听器 17 | RouteHistoryObserver.init(); 18 | //强制竖屏 19 | ScreenUtils.setPreferredOrientation(); 20 | //暗黑变化监听, (主题变化监听,强制页面UI更新) 21 | AppLifeCycleDelegate(); 22 | //透明状态栏 23 | ScreenUtils.setSystemTransparent(); 24 | //整理日志文件 25 | ConsoleOutput().clearUpLogFile(); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /lib/core/base/arguments.dart: -------------------------------------------------------------------------------- 1 | import 'dart:collection'; 2 | 3 | /// Arguments参数数据 4 | mixin ArgumentsMixin { 5 | late final Object? arguments; 6 | } 7 | 8 | /// 路由拼接的参数数据 9 | mixin RouteQueryMixin { 10 | final Map routeParams = HashMap(); 11 | } 12 | -------------------------------------------------------------------------------- /lib/core/base/navigation_history_observer.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | 3 | import 'package:built_collection/built_collection.dart'; 4 | import 'package:flutter/widgets.dart'; 5 | 6 | class NavigationHistoryObserver extends NavigatorObserver { 7 | final List?> _history = ?>[]; 8 | 9 | BuiltList> get history => 10 | BuiltList>.from(_history); 11 | 12 | Route? get top => _history.last; 13 | 14 | final List?> _poppedRoutes = ?>[]; 15 | 16 | BuiltList> get poppedRoutes => 17 | BuiltList>.from(_poppedRoutes); 18 | 19 | Route? get next => _poppedRoutes.last; 20 | 21 | final StreamController _historyChangeStreamController = 22 | StreamController.broadcast(); 23 | 24 | Stream get historyChangeStream => 25 | _historyChangeStreamController.stream; 26 | 27 | static final NavigationHistoryObserver _singleton = 28 | NavigationHistoryObserver._internal(); 29 | 30 | NavigationHistoryObserver._internal(); 31 | 32 | factory NavigationHistoryObserver() { 33 | return _singleton; 34 | } 35 | 36 | @override 37 | void didPop(Route route, Route? previousRoute) { 38 | _poppedRoutes.add(_history.last); 39 | _history.removeLast(); 40 | _historyChangeStreamController.add(HistoryChange( 41 | action: NavigationStackAction.pop, 42 | newRoute: route, 43 | oldRoute: previousRoute, 44 | )); 45 | } 46 | 47 | @override 48 | void didPush(Route route, Route? previousRoute) { 49 | _history.add(route); 50 | _poppedRoutes.remove(route); 51 | _historyChangeStreamController.add(HistoryChange( 52 | action: NavigationStackAction.push, 53 | newRoute: route, 54 | oldRoute: previousRoute, 55 | )); 56 | } 57 | 58 | @override 59 | void didRemove(Route route, Route? previousRoute) { 60 | _history.remove(route); 61 | _historyChangeStreamController.add(HistoryChange( 62 | action: NavigationStackAction.remove, 63 | newRoute: route, 64 | oldRoute: previousRoute, 65 | )); 66 | } 67 | 68 | @override 69 | void didReplace({Route? newRoute, Route? oldRoute}) { 70 | int oldRouteIndex = _history.indexOf(oldRoute); 71 | _history.replaceRange(oldRouteIndex, oldRouteIndex + 1, [newRoute]); 72 | _historyChangeStreamController.add(HistoryChange( 73 | action: NavigationStackAction.replace, 74 | newRoute: newRoute, 75 | oldRoute: oldRoute, 76 | )); 77 | } 78 | } 79 | 80 | class HistoryChange { 81 | HistoryChange({this.action, this.newRoute, this.oldRoute}); 82 | 83 | final NavigationStackAction? action; 84 | final Route? newRoute; 85 | final Route? oldRoute; 86 | } 87 | 88 | enum NavigationStackAction { push, pop, remove, replace } 89 | -------------------------------------------------------------------------------- /lib/core/error/flutter_error.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/cupertino.dart'; 2 | import 'package:flutter/foundation.dart'; 3 | import 'package:flutter_project/util/logger_util.dart'; 4 | 5 | class ErrorHelper { 6 | /// 异常捕获处理 7 | static void init() { 8 | //捕获异常 9 | FlutterError.onError = (errorDetails) { 10 | Log().d('FlutterError onError!'); 11 | _logError(errorDetails.exception, errorDetails.stack); 12 | }; 13 | //捕获异步异常 14 | PlatformDispatcher.instance.onError = (error, stack) { 15 | Log().d('PlatformDispatcher onError!'); 16 | _logError(error, stack); 17 | return true; 18 | }; 19 | // 自定义报错页面 20 | ErrorWidget.builder = (FlutterErrorDetails flutterErrorDetails) { 21 | Log().d(flutterErrorDetails.toString()); 22 | return const Center(child: Text("App Error")); 23 | }; 24 | } 25 | 26 | /// 打印日志,存到日志文件中 27 | static Future _logError(dynamic error, dynamic stackTrace) async { 28 | String logMessage = ''' 29 | ---------------- APP Exception ---------------- 30 | $error$stackTrace 31 | ---------------- APP Exception ---------------- 32 | '''; 33 | Log().d(logMessage); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /lib/core/http/http_api.dart: -------------------------------------------------------------------------------- 1 | import 'package:dio/dio.dart'; 2 | import 'package:flutter_project/core/http/http_request.dart'; 3 | 4 | mixin HttpApi { 5 | ///API 请求 6 | Future request({ 7 | required Method method, 8 | required String path, 9 | dynamic params, 10 | Success? success, 11 | Fail? fail, 12 | Complete? complete, 13 | Map? header, 14 | CancelToken? cancelToken, 15 | ProgressCallback? onSendProgress, 16 | }) { 17 | return HttpRequest.request( 18 | method, 19 | path, 20 | params, 21 | header, 22 | success: success, 23 | fail: fail, 24 | complete: complete, 25 | cancelToken: cancelToken, 26 | onSendProgress: onSendProgress, 27 | ); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /lib/core/http/http_exception.dart: -------------------------------------------------------------------------------- 1 | import 'dart:io'; 2 | 3 | import 'package:dio/dio.dart'; 4 | 5 | /// 错误信息处理 6 | class HttpException { 7 | static const int unknownError = 0; 8 | static const int socketError = 10000; 9 | static const int httpError = 10001; 10 | static const int parseError = 10002; 11 | static const int timeoutError = 10003; 12 | static const int cancelError = 10004; 13 | static const int netError = 10005; 14 | 15 | static const String netWorkError = 16 | "Network error. Please check your connection and try again."; 17 | static const String errorOccur = "Error Occurred"; 18 | static const String requestTimeout = "Request Timeout"; 19 | 20 | /// 错误信息处理 21 | /// [error] 错误信息类型 22 | static NetError handleException(DioError error) { 23 | switch (error.type) { 24 | case DioErrorType.response: 25 | dynamic e = error.error; 26 | if (e is SocketException) { 27 | return NetError(socketError, netWorkError); 28 | } else if (e is HttpException) { 29 | return NetError(httpError, errorOccur); 30 | } else if (e is FormatException) { 31 | return NetError(parseError, errorOccur); 32 | } else { 33 | return NetError(netError, netWorkError); 34 | } 35 | case DioErrorType.connectTimeout: 36 | case DioErrorType.receiveTimeout: 37 | return NetError(timeoutError, requestTimeout); 38 | case DioErrorType.cancel: 39 | return NetError(cancelError, errorOccur); 40 | default: 41 | return NetError(unknownError, errorOccur); 42 | } 43 | } 44 | } 45 | 46 | class NetError { 47 | int code; 48 | String msg; 49 | 50 | NetError(this.code, this.msg); 51 | } 52 | -------------------------------------------------------------------------------- /lib/core/http/http_request.dart: -------------------------------------------------------------------------------- 1 | import 'dart:convert'; 2 | import 'dart:io'; 3 | 4 | import 'package:connectivity/connectivity.dart'; 5 | import 'package:dio/dio.dart'; 6 | import 'package:flutter/cupertino.dart'; 7 | import 'package:flutter_project/core/http/http_exception.dart'; 8 | import 'package:flutter_project/core/http/http_url.dart'; 9 | import 'package:flutter_project/util/device_util.dart'; 10 | import 'package:flutter_project/util/logger_util.dart'; 11 | import 'package:flutter_project/util/sp_util.dart'; 12 | 13 | /// 连接超时时间 14 | const int _connectTimeout = 15000; 15 | 16 | /// 发送超时时间 17 | const int _sendTimeout = 15000; 18 | 19 | /// 成功回调 20 | typedef Success = Function(T data); 21 | 22 | /// 失败回调 23 | typedef Fail = Function(int code, String msg); 24 | 25 | /// 完成回调 26 | typedef Complete = VoidCallback; 27 | 28 | /// 请求工具 29 | class HttpRequest { 30 | static Dio? _dio; 31 | 32 | static Dio get dio => createInstance(); 33 | 34 | /// 创建 dio 实例对象 35 | static Dio createInstance({int receiveTimeout = 10000}) { 36 | if (_dio == null) { 37 | var options = BaseOptions( 38 | contentType: Headers.jsonContentType, 39 | validateStatus: (status) => true, 40 | sendTimeout: _sendTimeout, 41 | connectTimeout: _connectTimeout, 42 | receiveTimeout: receiveTimeout, 43 | baseUrl: HttpUrl.baseUrl, 44 | ); 45 | _dio = Dio(options); 46 | } 47 | return _dio!; 48 | } 49 | 50 | static resetDio() { 51 | _dio = null; 52 | createInstance(); 53 | } 54 | 55 | /// 请求,返回参数为 T 56 | static Future request( 57 | Method method, 58 | String path, 59 | dynamic params, 60 | Map? header, { 61 | Success? success, 62 | Fail? fail, 63 | Complete? complete, 64 | CancelToken? cancelToken, 65 | ProgressCallback? onSendProgress, 66 | }) async { 67 | try { 68 | var connectivityResult = await (Connectivity().checkConnectivity()); 69 | if (connectivityResult == ConnectivityResult.none) { 70 | fail?.call(HttpException.netError, HttpException.netWorkError); 71 | return Future.value(null); 72 | } 73 | Dio dio = createInstance(); 74 | Log().d("request url -> $path request param:$params"); 75 | Response response = await dio.request( 76 | path, 77 | data: params, 78 | cancelToken: cancelToken, 79 | onSendProgress: onSendProgress, 80 | options: Options( 81 | method: _methodValues[method], 82 | headers: await _headerToken(header, url: path), 83 | ), 84 | ); 85 | success?.call(response.data as T); 86 | return Future.value(response.data as T); 87 | } on DioError catch (e) { 88 | final NetError netError = HttpException.handleException(e); 89 | fail?.call(netError.code, netError.msg); 90 | Log().d( 91 | "error =====> message: ${e.message},\ntype:${e.type},\nresponse:${e.response}, \nerror:${e.error}"); 92 | return Future.value(null); 93 | } finally { 94 | complete?.call(); 95 | } 96 | } 97 | } 98 | 99 | Future?> _headerToken(Map? optionalHeader, 100 | {String? url}) async { 101 | String sysName = Platform.isIOS ? "iOS" : "Android"; 102 | String appVersion = await DeviceUtil.appVersion(); 103 | String appName = await DeviceUtil.appName(); 104 | String model = await DeviceUtil.phoneModel(); 105 | String osVersion = await DeviceUtil.systemVersion(); 106 | String? token = SpUtil.getToken(); 107 | Map httpHeaders = { 108 | "Model-Type": "PHONE", 109 | "Os-Type": sysName, 110 | "Os-Version": osVersion, 111 | "Phone-Model": model, 112 | "App-Version": appVersion, 113 | "App-Name": appName, 114 | "token": token, 115 | }; 116 | if (optionalHeader != null) { 117 | httpHeaders.addAll(optionalHeader); 118 | } 119 | Log().d("$url request header -> ${httpHeaders.toString()}"); 120 | return httpHeaders; 121 | } 122 | 123 | 124 | Map parseData(String data) { 125 | return json.decode(data) as Map; 126 | } 127 | 128 | enum Method { get, post, delete, put, patch, head } 129 | 130 | const _methodValues = { 131 | Method.get: "get", 132 | Method.post: "post", 133 | Method.delete: "delete", 134 | Method.put: "put", 135 | Method.patch: "patch", 136 | Method.head: "head", 137 | }; 138 | -------------------------------------------------------------------------------- /lib/core/http/http_url.dart: -------------------------------------------------------------------------------- 1 | class HttpUrl { 2 | static const String baseUrl = ""; 3 | static const String loginUrl = "https://www.baidu.com"; 4 | } 5 | -------------------------------------------------------------------------------- /lib/main_beta.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | import 'core/app/app.dart'; 4 | 5 | void main() { 6 | WidgetsFlutterBinding.ensureInitialized(); 7 | initApp(Env.beta); 8 | } 9 | -------------------------------------------------------------------------------- /lib/main_mp.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | import 'core/app/app.dart'; 4 | 5 | void main() { 6 | WidgetsFlutterBinding.ensureInitialized(); 7 | initApp(Env.mp); 8 | } -------------------------------------------------------------------------------- /lib/main_qa.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_project/core/app/app.dart'; 3 | 4 | // flutter run --flavor mp --target lib/main_mp.dart 5 | // flutter build apk --no-shrink --flavor mp --target lib/main_mp.dart 6 | void main() { 7 | WidgetsFlutterBinding.ensureInitialized(); 8 | initApp(Env.qa); 9 | } 10 | -------------------------------------------------------------------------------- /lib/model/language.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_project/res/intl/string_res_key.dart'; 2 | 3 | class Language { 4 | String defName = ''; 5 | String name = ''; 6 | String language = ''; 7 | String country = ''; 8 | 9 | Language(this.defName, this.name, this.language, this.country); 10 | 11 | Language.fromJson(Map json) 12 | : defName = json['defName'], 13 | name = json['name'], 14 | language = json['language'], 15 | country = json['country']; 16 | 17 | Map toJson() => { 18 | 'name': name, 19 | 'defName': defName, 20 | 'language': language, 21 | 'country': country, 22 | }; 23 | 24 | @override 25 | String toString() { 26 | return 'Language{defName: $defName, name: $name, language: $language, country: $country}'; 27 | } 28 | } 29 | 30 | final defLanguage = Language('English', RS.english, 'en', 'US'); 31 | 32 | final languageList = [ 33 | Language('English(US)', RS.english, 'en', 'US'), 34 | Language('English(UK)', RS.english, 'en', 'UK'), 35 | Language('中文', RS.chinese, 'zh', 'cn'), 36 | Language('日本語', RS.japanese, 'ja', 'JP'), 37 | ]; 38 | -------------------------------------------------------------------------------- /lib/page/code/binding.dart: -------------------------------------------------------------------------------- 1 | import 'package:get/get.dart'; 2 | 3 | import 'logic.dart'; 4 | 5 | class CodeBinding extends Bindings { 6 | @override 7 | void dependencies() { 8 | Get.lazyPut(() => CodeLogic()); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /lib/page/code/logic.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | 3 | import 'package:flutter/cupertino.dart'; 4 | import 'package:flutter_project/page/login/logic.dart'; 5 | import 'package:flutter_project/router/routers.dart'; 6 | import 'package:flutter_project/util/sp_util.dart'; 7 | import 'package:flutter_project/util/user_util.dart'; 8 | import 'package:get/get.dart'; 9 | 10 | import 'state.dart'; 11 | 12 | class CodeLogic extends GetxController { 13 | final CodeState state = CodeState(); 14 | final int time = 60; 15 | Timer? _timer; 16 | 17 | ///手机号后四位 18 | String get phoneNum { 19 | final loginLogic = Get.find(); 20 | var phone = loginLogic.state.phoneNum.value; 21 | if (phone.isNotEmpty && phone.length == 11) { 22 | return phone.substring(phone.length - 4); 23 | } 24 | return ""; 25 | } 26 | 27 | /// 验证码输入完成 28 | void codeInputCompleted({required String code}) { 29 | state.code.value = code; 30 | } 31 | 32 | /// 验证码是否输入完毕 33 | bool get codeIsCompleted { 34 | return state.code.value.length == 4; 35 | } 36 | 37 | @override 38 | void onReady() { 39 | super.onReady(); 40 | _startTimer(); 41 | } 42 | 43 | ///打开计时器 44 | void _startTimer() { 45 | _stopTimer(); 46 | state.countDownNum.value = time; 47 | _timer = Timer.periodic(const Duration(seconds: 1), (Timer t) { 48 | if (state.countDownNum.value <= 0) { 49 | state.countDownNum.value = -1; 50 | return; 51 | } 52 | state.countDownNum.value--; 53 | }); 54 | } 55 | 56 | ///停止计时器 57 | void _stopTimer() { 58 | _timer?.cancel(); 59 | _timer = null; 60 | } 61 | 62 | @override 63 | void onClose() { 64 | _stopTimer(); 65 | super.onClose(); 66 | } 67 | 68 | ///重新发送 69 | void reSendCode() { 70 | //发送代码 71 | _startTimer(); 72 | } 73 | 74 | ///下一步 75 | void next(BuildContext context) { 76 | if (!codeIsCompleted) { 77 | return; 78 | } 79 | //模拟登录获取到的票据 80 | UserUtil.setToken(token: "ABCDEFGHIJKLMN"); 81 | Get.offAllNamed(Routers.homePage); 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /lib/page/code/state.dart: -------------------------------------------------------------------------------- 1 | import 'package:get/get.dart'; 2 | 3 | class CodeState { 4 | var code = "".obs; 5 | var countDownNum = 60.obs; 6 | } 7 | -------------------------------------------------------------------------------- /lib/page/guide/logic.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | 3 | import 'package:flutter/cupertino.dart'; 4 | import 'package:flutter_project/page/page_ext.dart'; 5 | import 'package:flutter_project/util/sp_util.dart'; 6 | import 'package:get/get.dart'; 7 | 8 | import 'state.dart'; 9 | 10 | class GuideLogic extends GetxController { 11 | final GuideState state = GuideState(); 12 | PageController pageController = PageController(); 13 | Timer? _timer; 14 | 15 | @override 16 | void onReady() { 17 | super.onReady(); 18 | _startLoopGuide(); 19 | } 20 | 21 | /// 启动轮询器,每隔3秒切换到下一页 22 | void _startLoopGuide() { 23 | _timer = Timer.periodic(const Duration(seconds: 3), (timer) { 24 | state.currentPageIndex.value = state.currentPageIndex.value == 2 25 | ? 0 26 | : state.currentPageIndex.value + 1; 27 | pageController.animateToPage( 28 | state.currentPageIndex.value, 29 | duration: const Duration(milliseconds: 300), 30 | curve: Curves.easeInOut, 31 | ); 32 | }); 33 | } 34 | 35 | ///停止轮询 36 | void _stopLoopGuide() { 37 | _timer?.cancel(); 38 | _timer == null; 39 | } 40 | 41 | ///我要招人 42 | void findPeople() { 43 | _stopLoopGuide(); 44 | SpUtil.appIsOpen(); 45 | jumpHomePage(); 46 | } 47 | 48 | ///我要应聘 49 | void findWork() { 50 | _stopLoopGuide(); 51 | SpUtil.appIsOpen(); 52 | jumpHomePage(); 53 | } 54 | 55 | @override 56 | void onClose() { 57 | _stopLoopGuide(); 58 | super.onClose(); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /lib/page/guide/state.dart: -------------------------------------------------------------------------------- 1 | import 'package:get/get.dart'; 2 | 3 | class GuideState { 4 | RxInt currentPageIndex = 0.obs; 5 | } 6 | -------------------------------------------------------------------------------- /lib/page/home/binding.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_project/page/home/child/message/logic.dart'; 2 | import 'package:flutter_project/page/home/child/mine/logic.dart'; 3 | import 'package:flutter_project/page/home/child/work/logic.dart'; 4 | import 'package:flutter_project/page/home/child/youle/logic.dart'; 5 | import 'package:get/get.dart'; 6 | 7 | import 'logic.dart'; 8 | 9 | class HomeBinding extends Bindings { 10 | @override 11 | void dependencies() { 12 | Get.lazyPut(() => HomeLogic()); 13 | Get.lazyPut(() => WorkLogic()); 14 | Get.lazyPut(() => YouleLogic()); 15 | Get.lazyPut(() => MessageLogic()); 16 | Get.lazyPut(() => MineLogic()); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /lib/page/home/child/message/logic.dart: -------------------------------------------------------------------------------- 1 | import 'package:get/get.dart'; 2 | 3 | import 'state.dart'; 4 | 5 | class MessageLogic extends GetxController { 6 | final MessageState state = MessageState(); 7 | } 8 | -------------------------------------------------------------------------------- /lib/page/home/child/message/state.dart: -------------------------------------------------------------------------------- 1 | class MessageState { 2 | MessageState() { 3 | ///Initialize variables 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /lib/page/home/child/message/view.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:get/get.dart'; 3 | 4 | import 'logic.dart'; 5 | 6 | class MessagePage extends StatelessWidget { 7 | const MessagePage({Key? key}) : super(key: key); 8 | 9 | @override 10 | Widget build(BuildContext context) { 11 | final logic = Get.put(MessageLogic()); 12 | final state = Get.find().state; 13 | 14 | return Container( 15 | color: Colors.red, 16 | ); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /lib/page/home/child/mine/logic.dart: -------------------------------------------------------------------------------- 1 | import 'package:get/get.dart'; 2 | 3 | import 'state.dart'; 4 | 5 | class MineLogic extends GetxController { 6 | final MineState state = MineState(); 7 | } 8 | -------------------------------------------------------------------------------- /lib/page/home/child/mine/state.dart: -------------------------------------------------------------------------------- 1 | class MineState { 2 | MineState() { 3 | ///Initialize variables 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /lib/page/home/child/mine/view.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:get/get.dart'; 3 | 4 | import 'logic.dart'; 5 | 6 | class MinePage extends StatelessWidget { 7 | const MinePage({Key? key}) : super(key: key); 8 | 9 | @override 10 | Widget build(BuildContext context) { 11 | final logic = Get.put(MineLogic()); 12 | final state = Get.find().state; 13 | 14 | return Container( 15 | color: Colors.yellow, 16 | ); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /lib/page/home/child/work/logic.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:get/get.dart'; 3 | 4 | import '../../../../util/logger_util.dart'; 5 | import 'state.dart'; 6 | 7 | class WorkLogic extends GetxController with GetSingleTickerProviderStateMixin { 8 | final WorkState state = WorkState(); 9 | 10 | TabController? tabController; 11 | 12 | String get cityName { 13 | return state.titleTabs[tabController?.index ?? 0].address; 14 | } 15 | 16 | @override 17 | void onInit() { 18 | super.onInit(); 19 | tabController = TabController( 20 | vsync: this, 21 | length: state.titleTabs.length, 22 | ); 23 | tabController?.addListener(() { 24 | state.currentIndex.value = tabController?.index ?? 0; 25 | state.currentFilter.value = TabFilterEnum.recommend; 26 | Log().d("-----offset:${tabController?.offset ?? 0}"); 27 | }); 28 | } 29 | 30 | @override 31 | void onClose() { 32 | tabController?.dispose(); 33 | super.onClose(); 34 | } 35 | 36 | /// 切换tab筛选 37 | void changeTabFilter(TabFilterEnum tabFilterEnum) { 38 | state.currentFilter.value = tabFilterEnum; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /lib/page/home/child/work/state.dart: -------------------------------------------------------------------------------- 1 | import 'package:get/get.dart'; 2 | 3 | ///职位tab 4 | class WorkTab { 5 | int index; 6 | String text; 7 | String address; 8 | 9 | WorkTab({ 10 | required this.index, 11 | required this.text, 12 | required this.address, 13 | }); 14 | } 15 | 16 | /// 筛选类型 17 | enum TabFilterEnum { 18 | // 推荐 19 | recommend, 20 | // 附近 21 | nearby, 22 | // 最新 23 | latest, 24 | } 25 | 26 | extension WorkFilterExt on TabFilterEnum { 27 | ///名称 28 | String get filterName { 29 | switch (this) { 30 | case TabFilterEnum.recommend: 31 | return "推荐"; 32 | case TabFilterEnum.nearby: 33 | return "附近"; 34 | case TabFilterEnum.latest: 35 | return "最新"; 36 | } 37 | } 38 | } 39 | 40 | class WorkState { 41 | /// Tab数据 42 | final List titleTabs = [ 43 | WorkTab( 44 | text: 'Android', 45 | index: 0, 46 | address: '南京', 47 | ), 48 | WorkTab( 49 | text: 'Android', 50 | index: 1, 51 | address: '北京', 52 | ), 53 | WorkTab( 54 | text: 'Android', 55 | index: 2, 56 | address: '上海', 57 | ), 58 | ]; 59 | 60 | /// 当前tab 筛选 61 | Rx currentFilter = TabFilterEnum.recommend.obs; 62 | 63 | /// 当前索引 64 | RxInt currentIndex = 0.obs; 65 | 66 | } 67 | -------------------------------------------------------------------------------- /lib/page/home/child/work/work_test_data_helper.dart: -------------------------------------------------------------------------------- 1 | import 'dart:math'; 2 | 3 | import '../../../../model/Work_model.dart'; 4 | 5 | class TestDataGenerator { 6 | static List generateTestData(int count) { 7 | List testData = []; 8 | for (int i = 0; i < count; i++) { 9 | testData.add(_generateRandomWorkModel()); 10 | } 11 | return testData; 12 | } 13 | 14 | static WorkModel _generateRandomWorkModel() { 15 | return WorkModel( 16 | name: _generateRandomString(10), 17 | status: _generateRandomStatus(), 18 | salaryRange: _generateRandomSalaryRange(), 19 | companyName: _generateRandomString(10), 20 | financingStage: _generateRandomFinancingStage(), 21 | employeeNum: _generateRandomEmployeeNum(), 22 | tags: _generateRandomTags(), 23 | commutingTime: _generateRandomCommutingTime(), 24 | address: _generateRandomAddressString(15), 25 | recruiter: _generateRandomRecruiter(), 26 | ); 27 | } 28 | 29 | static String _generateRandomString(int length) { 30 | return ['Android开发', 'Flutter开发', '鸿蒙开发工程师'][Random().nextInt(3)]; 31 | } 32 | 33 | static String _generateRandomAddressString(int length) { 34 | return ['北京海淀区', '上海市杨浦区', '南京路'][Random().nextInt(3)]; 35 | } 36 | 37 | static String _generateRandomStatus() { 38 | return ['急聘', ''][Random().nextInt(2)]; 39 | } 40 | 41 | static String _generateRandomSalaryRange() { 42 | return ['3-6万元', '5-8万元', '8-12万元'][Random().nextInt(3)]; 43 | } 44 | 45 | static String _generateRandomFinancingStage() { 46 | return ['已上市', 'A轮', 'B轮', 'C轮', 'D轮及以上', '未融资'][Random().nextInt(6)]; 47 | } 48 | 49 | static String _generateRandomEmployeeNum() { 50 | return [ 51 | '1000以下', 52 | '1000-5000人', 53 | '5000-10000人', 54 | '10000以上' 55 | ][Random().nextInt(4)]; 56 | } 57 | 58 | static List _generateRandomTags() { 59 | return ['本科', '硕士', '博士', '设计模式', 'SDK', '算法', 'Java', 'Python'] 60 | .sublist(0, Random().nextInt(8) + 1); 61 | } 62 | 63 | static String _generateRandomCommutingTime() { 64 | return ['地铁30分钟', '地铁1小时', '公交30分钟', '公交1小时', '自驾'][Random().nextInt(5)]; 65 | } 66 | 67 | static Recruiter _generateRandomRecruiter() { 68 | return Recruiter( 69 | name: '周先生', 70 | icon: 71 | 'https://img1.baidu.com/it/u=1308060489,3520735740&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=750', 72 | position: ['HR', '招聘经理', '人事专员'][Random().nextInt(3)], 73 | status: '今天回复${Random().nextInt(20)}次', 74 | ); 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /lib/page/home/child/youle/logic.dart: -------------------------------------------------------------------------------- 1 | import 'package:get/get.dart'; 2 | 3 | import 'state.dart'; 4 | 5 | class YouleLogic extends GetxController { 6 | final YouleState state = YouleState(); 7 | } 8 | -------------------------------------------------------------------------------- /lib/page/home/child/youle/state.dart: -------------------------------------------------------------------------------- 1 | class YouleState { 2 | YouleState() { 3 | ///Initialize variables 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /lib/page/home/child/youle/view.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:get/get.dart'; 3 | 4 | import 'logic.dart'; 5 | 6 | class YoulePage extends StatelessWidget { 7 | const YoulePage({Key? key}) : super(key: key); 8 | 9 | @override 10 | Widget build(BuildContext context) { 11 | final logic = Get.put(YouleLogic()); 12 | final state = Get.find().state; 13 | 14 | return Container( 15 | color: Colors.deepOrange, 16 | ); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /lib/page/home/logic.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/cupertino.dart'; 2 | import 'package:flutter_project/core/http/http_api.dart'; 3 | import 'package:get/get.dart'; 4 | 5 | import 'state.dart'; 6 | 7 | class HomeLogic extends GetxController with HttpApi { 8 | final HomeState state = HomeState(); 9 | late PageController pageController; 10 | 11 | 12 | /// 处理tab默认显示索引 13 | void handleCurrentIndex({required Map params}) { 14 | int size = state.homeBottomBar.length; 15 | if (params != null) { 16 | int tabIndex = params["tabIndex"] ?? 0; 17 | // 默认加载页面 18 | if (tabIndex >= size) { 19 | state.currentIndex.value = size - 1; 20 | } else { 21 | state.currentIndex.value = tabIndex; 22 | } 23 | } 24 | // 初始化tab控制器 25 | pageController = PageController(initialPage: state.currentIndex.value, keepPage: true); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /lib/page/home/state.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_project/page/home/child/message/view.dart'; 3 | import 'package:flutter_project/page/home/child/mine/view.dart'; 4 | import 'package:flutter_project/page/home/child/work/view.dart'; 5 | import 'package:flutter_project/page/home/child/youle/view.dart'; 6 | import 'package:get/get.dart'; 7 | 8 | class HomeTab { 9 | HomeTab({ 10 | required this.tabName, 11 | required this.tabIcon, 12 | required this.tabSelectedIcon, 13 | required this.child, 14 | this.badger = 0, 15 | }); 16 | 17 | String tabName; 18 | String tabIcon; 19 | String tabSelectedIcon; 20 | Widget child; 21 | int badger; 22 | } 23 | 24 | class HomeState { 25 | ///当前索引 26 | RxInt currentIndex = 0.obs; 27 | 28 | /// Boss 底部按钮 29 | final List homeBottomBar = [ 30 | HomeTab( 31 | tabName: '职位', 32 | tabIcon: 'assets/images/tabbar/zhiwei.png', 33 | tabSelectedIcon: 'assets/images/tabbar/zhiwei.webp', 34 | child: const WorkPage(), 35 | ), 36 | HomeTab( 37 | tabName: '有了', 38 | tabIcon: 'assets/images/tabbar/youle.png', 39 | tabSelectedIcon: 'assets/images/tabbar/youle.webp', 40 | child: const YoulePage()), 41 | HomeTab( 42 | tabName: '消息', 43 | tabIcon: 'assets/images/tabbar/xiaoxi-c.png', 44 | tabSelectedIcon: 'assets/images/tabbar/xiaoxi-c.webp', 45 | child: const MessagePage()), 46 | HomeTab( 47 | tabName: '我的', 48 | tabIcon: 'assets/images/tabbar/wode-c.png', 49 | tabSelectedIcon: 'assets/images/tabbar/wode-c.webp', 50 | child: const MinePage()), 51 | ]; 52 | 53 | ///lottie 底部按钮 54 | // final List homeBottomBar = [ 55 | // HomeTab( 56 | // tabName: '职位', 57 | // tabIcon: 'assets/lottie/tab/zhiwei.json', 58 | // child: const WorkPage()), 59 | // HomeTab( 60 | // tabName: '有了', 61 | // tabIcon: 'assets/lottie/tab/youle.json', 62 | // child: const YoulePage()), 63 | // HomeTab( 64 | // tabName: '消息', 65 | // tabIcon: 'assets/lottie/tab/xiaoxi-c.json', 66 | // child: const MessagePage()), 67 | // HomeTab( 68 | // tabName: '我的', 69 | // tabIcon: 'assets/lottie/tab/wode-c.json', 70 | // child: const MinePage()), 71 | // ]; 72 | } 73 | -------------------------------------------------------------------------------- /lib/page/home/view.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_project/core/base/arguments.dart'; 3 | import 'package:flutter_project/core/base/page_state.dart'; 4 | import 'package:flutter_project/widgets/bottom_bar_item.dart'; 5 | import 'package:get/get.dart'; 6 | 7 | import 'logic.dart'; 8 | 9 | class HomePage extends StatefulWidget with RouteQueryMixin { 10 | HomePage({Key? key}) : super(key: key); 11 | 12 | @override 13 | State createState() { 14 | return HomeState(); 15 | } 16 | } 17 | 18 | class HomeState extends PageState with AutomaticKeepAliveClientMixin { 19 | final logic = Get.put(HomeLogic()); 20 | 21 | @override 22 | void initState() { 23 | super.initState(); 24 | logic.handleCurrentIndex(params: widget.routeParams); 25 | } 26 | 27 | @override 28 | Widget build(BuildContext context) { 29 | super.build(context); 30 | return Scaffold( 31 | body: _homeBodyWidget(context), 32 | ); 33 | } 34 | 35 | Widget _homeBodyWidget(BuildContext context) { 36 | return Scaffold( 37 | body: Stack( 38 | alignment: Alignment.bottomCenter, 39 | children: [ 40 | // 子布局 41 | PageView( 42 | controller: logic.pageController, 43 | physics: const NeverScrollableScrollPhysics(), 44 | children: _bodyContentWidget(), 45 | onPageChanged: (index) { 46 | logic.state.currentIndex.value = index; 47 | }, 48 | ), 49 | ], 50 | ), 51 | 52 | // 底部栏 53 | bottomNavigationBar: Obx( 54 | () => BottomAppBar( 55 | elevation: 5.0, 56 | height: 50, 57 | child: Row( 58 | mainAxisAlignment: MainAxisAlignment.spaceAround, 59 | crossAxisAlignment: CrossAxisAlignment.center, 60 | children: List.generate( 61 | logic.state.homeBottomBar.length, 62 | (index) => Expanded( 63 | child: BottomBarItem( 64 | tabName: logic.state.homeBottomBar[index].tabName, 65 | tabIcon: logic.state.homeBottomBar[index].tabIcon, 66 | tabIndex: index, 67 | onTap: (index) { 68 | logic.state.currentIndex.value = index; 69 | logic.pageController.jumpToPage(index); 70 | }, 71 | isChecked: logic.state.currentIndex.value == index, 72 | tabSelectedIcon: 73 | logic.state.homeBottomBar[index].tabSelectedIcon, 74 | ), 75 | ), 76 | ), 77 | ), 78 | ), 79 | ), 80 | ); 81 | } 82 | 83 | @override 84 | bool get wantKeepAlive => true; 85 | 86 | /// 子布局集合 87 | List _bodyContentWidget() { 88 | return logic.state.homeBottomBar.map((item) => item.child).toList(); 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /lib/page/login/binding.dart: -------------------------------------------------------------------------------- 1 | import 'package:get/get.dart'; 2 | 3 | import 'logic.dart'; 4 | 5 | class LoginBinding extends Bindings { 6 | @override 7 | void dependencies() { 8 | Get.lazyPut(() => LoginLogic()); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /lib/page/login/logic.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/gestures.dart'; 2 | import 'package:flutter/material.dart'; 3 | import 'package:flutter_project/core/http/http_api.dart'; 4 | import 'package:flutter_project/res/colors/color_res.dart'; 5 | import 'package:flutter_project/router/routers.dart'; 6 | import 'package:flutter_project/util/regex_util.dart'; 7 | import 'package:flutter_project/util/toast_util.dart'; 8 | import 'package:get/get.dart'; 9 | 10 | import 'state.dart'; 11 | 12 | ///登录页面 13 | class LoginLogic extends GetxController with HttpApi { 14 | final LoginState state = LoginState(); 15 | final TextEditingController controller = TextEditingController(); 16 | 17 | /// 微信登录 18 | void wxLogin() { 19 | ToastUtil.show(msg: '微信登录'); 20 | } 21 | 22 | /// 下一步 23 | void next(BuildContext context) { 24 | //为空不能执行下一步 25 | if (state.phoneNum.value.isEmpty) { 26 | return; 27 | } 28 | //手机号不符合要求 29 | if (!RegexUtil.isMobileSimple(state.phoneNum.value)) { 30 | ToastUtil.show(msg: '请输入正确的手机号'); 31 | return; 32 | } 33 | if (!state.isAgree.value) { 34 | showDialog( 35 | context: context, 36 | builder: (BuildContext context) { 37 | return AlertDialog( 38 | content: RichText( 39 | text: TextSpan( 40 | text: '请阅读并同意', 41 | style: const TextStyle(color: Colors.black, fontSize: 16), 42 | children: [ 43 | TextSpan( 44 | text: '《BOSS直聘用户协议》', 45 | style: const TextStyle(color: RC.themeColor), 46 | recognizer: TapGestureRecognizer() 47 | ..onTap = () { 48 | ToastUtil.show(msg: "跳转到BOSS直聘用户协议"); 49 | }, 50 | ), 51 | const TextSpan( 52 | text: ' 和 ', 53 | style: TextStyle(color: Colors.black, fontSize: 16), 54 | ), 55 | TextSpan( 56 | text: '《隐私政策》', 57 | style: const TextStyle(color: RC.themeColor), 58 | recognizer: TapGestureRecognizer() 59 | ..onTap = () { 60 | ToastUtil.show(msg: "跳转到隐私政策"); 61 | }, 62 | ), 63 | const TextSpan( 64 | text: ',允许BOSS直聘统一管理本人账号信息', 65 | style: TextStyle(color: Colors.black, fontSize: 16), 66 | ), 67 | ], 68 | ), 69 | ), 70 | actions: [ 71 | TextButton( 72 | onPressed: () { 73 | Navigator.of(context).pop(); 74 | }, 75 | child: const Text( 76 | '拒绝', 77 | style: TextStyle( 78 | fontSize: 16, 79 | color: RC.themeColor, 80 | ), 81 | ), 82 | ), 83 | TextButton( 84 | onPressed: () { 85 | state.isAgree.value = true; 86 | Navigator.of(context).pop(); 87 | }, 88 | child: const Text( 89 | '同意', 90 | style: TextStyle( 91 | fontSize: 16, 92 | color: RC.themeColor, 93 | ), 94 | ), 95 | ), 96 | ], 97 | ); 98 | }, 99 | ); 100 | return; 101 | } 102 | 103 | //跳转到验证码界面 104 | Get.toNamed(Routers.codePage); 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /lib/page/login/state.dart: -------------------------------------------------------------------------------- 1 | import 'package:get/get.dart'; 2 | 3 | class LoginState { 4 | // 手机号 5 | RxString phoneNum = "".obs; 6 | 7 | // 是否同意协议 8 | RxBool isAgree = false.obs; 9 | } 10 | -------------------------------------------------------------------------------- /lib/page/page_ext.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_project/router/routers.dart'; 2 | import 'package:flutter_project/util/user_util.dart'; 3 | import 'package:get/get.dart'; 4 | 5 | /// 跳转到首页 6 | /// 已登录-跳转到首页 7 | /// 未登录-跳转到登录页面 8 | void jumpHomePage() { 9 | if (UserUtil.isLogin()) { 10 | Get.offAndToNamed(Routers.homePage); 11 | } else { 12 | Get.offAndToNamed(Routers.loginPage); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /lib/page/splash/binding.dart: -------------------------------------------------------------------------------- 1 | import 'package:get/get.dart'; 2 | 3 | import 'logic.dart'; 4 | 5 | class SplashBinding extends Bindings { 6 | @override 7 | void dependencies() { 8 | Get.lazyPut(() => SplashLogic()); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /lib/page/splash/logic.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/services.dart'; 2 | import 'package:get/get.dart'; 3 | 4 | import 'state.dart'; 5 | 6 | class SplashLogic extends GetxController { 7 | final SplashState state = SplashState(); 8 | 9 | @override 10 | void onInit() { 11 | super.onInit(); 12 | SystemChrome.setEnabledSystemUIMode( 13 | SystemUiMode.manual, 14 | overlays: [], 15 | ); 16 | } 17 | 18 | @override 19 | void onClose() { 20 | SystemChrome.setEnabledSystemUIMode( 21 | SystemUiMode.manual, 22 | overlays: SystemUiOverlay.values, 23 | ); 24 | super.onClose(); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /lib/page/splash/state.dart: -------------------------------------------------------------------------------- 1 | class SplashState { 2 | SplashState() { 3 | ///Initialize variables 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /lib/page/splash/view.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_project/page/guide/view.dart'; 3 | import 'package:flutter_project/page/welcome/view.dart'; 4 | import 'package:flutter_project/util/sp_util.dart'; 5 | import 'package:flutter_screenutil/flutter_screenutil.dart'; 6 | 7 | /// 启动页面-欢迎界面/引导页面 8 | class SplashPage extends StatelessWidget { 9 | const SplashPage({Key? key}) : super(key: key); 10 | 11 | @override 12 | Widget build(BuildContext context) { 13 | ScreenUtil.init(context, designSize: const Size(375, 812)); 14 | var child = SpUtil.isFirstOpen() ? const GuidePage() : const WelcomePage(); 15 | return Scaffold( 16 | body: child, 17 | resizeToAvoidBottomInset: false, 18 | ); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /lib/page/welcome/logic.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | 3 | import 'package:flutter_project/page/page_ext.dart'; 4 | import 'package:get/get.dart'; 5 | 6 | import 'state.dart'; 7 | 8 | class WelcomeLogic extends GetxController { 9 | final WelcomeState state = WelcomeState(); 10 | int _timeCount = 3; 11 | Timer? _timer; 12 | 13 | @override 14 | void onReady() { 15 | super.onReady(); 16 | _startTimer(); 17 | } 18 | 19 | ///打开计时器 20 | void _startTimer() { 21 | _timer = Timer.periodic(const Duration(seconds: 1), (Timer t) { 22 | state.adStr.value = "广告$_timeCount秒跳过"; 23 | if (_timeCount <= 0) { 24 | openHomePage(); 25 | return; 26 | } 27 | _timeCount--; 28 | }); 29 | } 30 | 31 | ///停止计时器 32 | void _stopTimer() { 33 | _timer?.cancel(); 34 | _timer = null; 35 | } 36 | 37 | /// 打开首页 38 | void openHomePage() { 39 | _stopTimer(); 40 | jumpHomePage(); 41 | } 42 | 43 | @override 44 | void onClose() { 45 | _stopTimer(); 46 | super.onClose(); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /lib/page/welcome/state.dart: -------------------------------------------------------------------------------- 1 | import 'package:get/get.dart'; 2 | 3 | class WelcomeState { 4 | RxString adStr = "广告3秒跳过".obs; 5 | } 6 | -------------------------------------------------------------------------------- /lib/page/welcome/view.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_project/res/images/r.dart'; 3 | import 'package:flutter_screenutil/flutter_screenutil.dart'; 4 | import 'package:get/get.dart'; 5 | 6 | import 'logic.dart'; 7 | 8 | /// 欢迎页面 9 | class WelcomePage extends StatelessWidget { 10 | const WelcomePage({Key? key}) : super(key: key); 11 | 12 | @override 13 | Widget build(BuildContext context) { 14 | final logic = Get.put(WelcomeLogic()); 15 | return WillPopScope( 16 | onWillPop: () { 17 | return Future.value(false); 18 | }, 19 | child: Stack( 20 | children: [ 21 | Positioned.fill( 22 | child: Container( 23 | color: const Color(0xFF40C2BB), 24 | width: double.infinity, 25 | height: double.infinity, 26 | child: Image.asset( 27 | R.splash_bg_jpg, 28 | fit: BoxFit.cover, 29 | ), 30 | ), 31 | ), 32 | Obx( 33 | () => Positioned( 34 | right: 16.w, 35 | top: 30.w, 36 | child: InkWell( 37 | child: Container( 38 | padding: EdgeInsets.symmetric(horizontal: 8.w, vertical: 3.w), 39 | decoration: BoxDecoration( 40 | border: Border.all(color: Colors.white, width: 1.w), 41 | borderRadius: BorderRadius.all(Radius.circular(8.w)), 42 | ), 43 | child: Text( 44 | logic.state.adStr.value, 45 | style: const TextStyle( 46 | color: Colors.white, 47 | fontSize: 14, 48 | fontWeight: FontWeight.w600, 49 | ), 50 | ), 51 | ), 52 | onTap: () { 53 | logic.openHomePage(); 54 | }, 55 | ), 56 | ), 57 | ), 58 | ], 59 | ), 60 | ); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /lib/res/colors/color_res.dart: -------------------------------------------------------------------------------- 1 | import 'dart:ui'; 2 | 3 | class RC { 4 | ///主题色 5 | static const Color themeColor = Color(0xFF40C2BB); 6 | static const Color pageBgColor = Color(0xFFF2F2F2); 7 | 8 | static const Color text1Color = Color(0xFF000000); 9 | static const Color text2Color = Color(0xFF666666); 10 | } 11 | -------------------------------------------------------------------------------- /lib/res/images/r.dart: -------------------------------------------------------------------------------- 1 | class R { 2 | static const String guide_one_png = 'assets/images/guide_one.png'; 3 | static const String guide_three_png = 'assets/images/guide_three.png'; 4 | static const String guide_two_png = 'assets/images/guide_two.png'; 5 | static const String image1_webp = 'assets/images/image1.webp'; 6 | static const String image2_webp = 'assets/images/image2.webp'; 7 | static const String image3_jpg = 'assets/images/image3.jpg'; 8 | static const String image4_webp = 'assets/images/image4.webp'; 9 | static const String image5_webp = 'assets/images/image5.webp'; 10 | static const String image6_webp = 'assets/images/image6.webp'; 11 | static const String image7_webp = 'assets/images/image7.webp'; 12 | static const String login_wx_png = 'assets/images/login_wx.png'; 13 | static const String splash_bg_jpg = 'assets/images/splash_bg.jpg'; 14 | static const String tabbar = 'assets/images/tabbar'; 15 | static const String work_top_bg_jpg = 'assets/images/work_top_bg.jpg'; 16 | } 17 | -------------------------------------------------------------------------------- /lib/res/intl/string_res.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_project/res/intl/strings/en_uk_res.dart'; 2 | import 'package:flutter_project/res/intl/strings/en_us_res.dart'; 3 | import 'package:flutter_project/res/intl/strings/ja_jp_res.dart'; 4 | import 'package:flutter_project/res/intl/strings/zh_cn_res.dart'; 5 | import 'package:get/get.dart'; 6 | 7 | /// 多语言配置 8 | class StringRes extends Translations { 9 | @override 10 | Map> get keys => { 11 | "en_US": enUsRes, 12 | "en_UK": enUkRes, 13 | "zh_CN": zhCnRes, 14 | "ja_JP": jaJpRes, 15 | }; 16 | } 17 | -------------------------------------------------------------------------------- /lib/res/intl/string_res_key.dart: -------------------------------------------------------------------------------- 1 | class RS { 2 | static const String appName = 'appName'; 3 | static const String chinese = 'chinese'; 4 | static const String english = 'english'; 5 | static const String japanese = 'japanese'; 6 | static const String findPeople = 'findPeople'; 7 | static const String findWork = 'findWork'; 8 | } 9 | -------------------------------------------------------------------------------- /lib/res/intl/strings/en_uk_res.dart: -------------------------------------------------------------------------------- 1 | import '../string_res_key.dart'; 2 | 3 | const enUkRes = { 4 | RS.appName: "Flutter Study", 5 | RS.chinese: "Chinese", 6 | RS.english: "English", 7 | RS.japanese: "Japanese", 8 | }; 9 | -------------------------------------------------------------------------------- /lib/res/intl/strings/en_us_res.dart: -------------------------------------------------------------------------------- 1 | import '../string_res_key.dart'; 2 | 3 | const enUsRes = { 4 | RS.appName: "Flutter Study", 5 | RS.chinese: "Chinese", 6 | RS.english: "English", 7 | RS.japanese: "Japanese", 8 | }; 9 | -------------------------------------------------------------------------------- /lib/res/intl/strings/ja_jp_res.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_project/res/intl/string_res_key.dart'; 2 | const jaJpRes = { 3 | RS.appName: "Flutter学習", 4 | RS.chinese: "中国語", 5 | RS.english: "英語", 6 | RS.japanese: "日本語", 7 | }; -------------------------------------------------------------------------------- /lib/res/intl/strings/zh_cn_res.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_project/res/intl/string_res_key.dart'; 2 | 3 | const zhCnRes = { 4 | RS.appName: "Flutter学习", 5 | RS.chinese: "中文", 6 | RS.english: "英语", 7 | RS.japanese: "日语", 8 | RS.findPeople: "我要招人", 9 | RS.findWork: "我要应聘", 10 | }; 11 | -------------------------------------------------------------------------------- /lib/router/routers.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_project/page/code/binding.dart'; 2 | import 'package:flutter_project/page/code/view.dart'; 3 | import 'package:flutter_project/page/home/binding.dart'; 4 | import 'package:flutter_project/page/home/view.dart'; 5 | import 'package:flutter_project/page/login/binding.dart'; 6 | import 'package:flutter_project/page/login/view.dart'; 7 | import 'package:flutter_project/page/splash/binding.dart'; 8 | import 'package:flutter_project/page/splash/view.dart'; 9 | import 'package:get/get.dart'; 10 | 11 | /// 页面管理路由表 12 | abstract class Routers { 13 | // 启动页 14 | static const String splashPage = '/splash'; 15 | 16 | // 首页 17 | static const String homePage = '/home'; 18 | 19 | // 登录 20 | static const String loginPage = '/login'; 21 | 22 | // 验证码 23 | static const String codePage = '/code'; 24 | 25 | static final routePages = [ 26 | GetPage( 27 | name: splashPage, 28 | page: () => const SplashPage(), 29 | binding: SplashBinding(), 30 | ), 31 | GetPage( 32 | name: homePage, 33 | page: () => HomePage(), 34 | binding: HomeBinding(), 35 | ), 36 | GetPage( 37 | name: loginPage, 38 | page: () => const LoginPage(), 39 | binding: LoginBinding(), 40 | ), 41 | GetPage( 42 | name: codePage, 43 | page: () => const CodePage(), 44 | binding: CodeBinding(), 45 | ), 46 | ]; 47 | } 48 | -------------------------------------------------------------------------------- /lib/util/device_util.dart: -------------------------------------------------------------------------------- 1 | import 'dart:io'; 2 | 3 | import 'package:device_info_plus/device_info_plus.dart'; 4 | import 'package:package_info_plus/package_info_plus.dart'; 5 | 6 | typedef JMap = Map; 7 | typedef LJMap = List; 8 | 9 | class DeviceUtil { 10 | /// 获取应用版本号 11 | static Future appVersion() async { 12 | PackageInfo packageInfo = await PackageInfo.fromPlatform(); 13 | return packageInfo.version; 14 | } 15 | 16 | /// 获取应用的bundle-id 17 | static Future packageName() async { 18 | PackageInfo packageInfo = await PackageInfo.fromPlatform(); 19 | return packageInfo.packageName; 20 | } 21 | 22 | /// 获取应用的build号 23 | static Future buildNumber() async { 24 | PackageInfo packageInfo = await PackageInfo.fromPlatform(); 25 | return packageInfo.buildNumber; 26 | } 27 | 28 | /// 获取应用名 29 | static Future appName() async { 30 | PackageInfo packageInfo = await PackageInfo.fromPlatform(); 31 | return packageInfo.appName; 32 | } 33 | 34 | /// 获取当前设备品牌 35 | static Future phoneBrand() async { 36 | DeviceInfoPlugin deviceInfo = DeviceInfoPlugin(); 37 | if (Platform.isIOS) { 38 | IosDeviceInfo iosInfo = await deviceInfo.iosInfo; 39 | return "Apple"; 40 | } else { 41 | AndroidDeviceInfo androidInfo = await deviceInfo.androidInfo; 42 | return androidInfo.brand ?? ''; 43 | } 44 | } 45 | 46 | /// 获取设备名称 47 | static Future phoneName() async { 48 | DeviceInfoPlugin deviceInfo = DeviceInfoPlugin(); 49 | if (Platform.isIOS) { 50 | IosDeviceInfo iosInfo = await deviceInfo.iosInfo; 51 | return iosInfo.name ?? ""; 52 | } else { 53 | AndroidDeviceInfo androidInfo = await deviceInfo.androidInfo; 54 | return androidInfo.display ?? ""; 55 | } 56 | } 57 | 58 | /// 获取设备型号 59 | static Future phoneModel() async { 60 | DeviceInfoPlugin deviceInfo = DeviceInfoPlugin(); 61 | if (Platform.isIOS) { 62 | IosDeviceInfo iosInfo = await deviceInfo.iosInfo; 63 | return iosInfo.model ?? ""; 64 | } else { 65 | AndroidDeviceInfo androidInfo = await deviceInfo.androidInfo; 66 | return androidInfo.model ?? ""; 67 | } 68 | } 69 | 70 | /// 获取设备型号 71 | static Future iosSystemVersion() async { 72 | return (await iosDeviceInfo()).systemVersion ?? ""; 73 | } 74 | 75 | /// 获取统一设备型号 76 | static Future systemVersion() async { 77 | if (Platform.isIOS) { 78 | return (await iosDeviceInfo()).systemVersion ?? ""; 79 | } else if (Platform.isAndroid) { 80 | return (await androidDeviceInfo()).version.release ?? ''; 81 | } 82 | return ''; 83 | } 84 | 85 | ///获取android设备信息 86 | static Future androidDeviceInfo() async { 87 | DeviceInfoPlugin deviceInfo = DeviceInfoPlugin(); 88 | return await deviceInfo.androidInfo; 89 | } 90 | 91 | ///获取ios设备信息 92 | static Future iosDeviceInfo() async { 93 | DeviceInfoPlugin deviceInfo = DeviceInfoPlugin(); 94 | return await deviceInfo.iosInfo; 95 | } 96 | 97 | /// newVersion 新版本号 old 老版本号 98 | static bool isUpdateVersion(String? newVersion, String? old) { 99 | if (newVersion == null || 100 | newVersion.isEmpty || 101 | old == null || 102 | old.isEmpty) { 103 | return false; 104 | } 105 | int newVersionInt, oldVersion; 106 | var newList = newVersion.split('.'); 107 | var oldList = old.split('.'); 108 | if (newList.isEmpty || oldList.isEmpty) { 109 | return false; 110 | } 111 | for (int i = 0; i < newList.length; i++) { 112 | newVersionInt = int.parse(newList[i]); 113 | oldVersion = int.parse(oldList[i]); 114 | if (newVersionInt > oldVersion) { 115 | return true; 116 | } else if (newVersionInt < oldVersion) { 117 | return false; 118 | } 119 | } 120 | return false; 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /lib/util/encrypt_util.dart: -------------------------------------------------------------------------------- 1 | import 'dart:convert'; 2 | 3 | import 'package:convert/convert.dart'; 4 | import 'package:crypto/crypto.dart'; 5 | 6 | class EncryptUtil { 7 | /// md5 加密 8 | static String encodeMd5(String data) { 9 | var content = const Utf8Encoder().convert(data); 10 | var digest = md5.convert(content); 11 | return hex.encode(digest.bytes); 12 | } 13 | 14 | /// 异或对称加密 15 | static String xorCode(String res, String key) { 16 | List keyList = key.split(','); 17 | List codeUnits = res.codeUnits; 18 | List codes = []; 19 | for (int i = 0, length = codeUnits.length; i < length; i++) { 20 | int code = codeUnits[i] ^ int.parse(keyList[i % keyList.length]); 21 | codes.add(code); 22 | } 23 | return String.fromCharCodes(codes); 24 | } 25 | 26 | /// 异或对称 Base64 加密 27 | static String xorBase64Encode(String res, String key) { 28 | String encode = xorCode(res, key); 29 | encode = encodeBase64(encode); 30 | return encode; 31 | } 32 | 33 | /// 异或对称 Base64 解密 34 | static String xorBase64Decode(String res, String key) { 35 | String encode = decodeBase64(res); 36 | encode = xorCode(encode, key); 37 | return encode; 38 | } 39 | 40 | /// Base64加密 41 | static String encodeBase64(String data) { 42 | var content = utf8.encode(data); 43 | var digest = base64Encode(content); 44 | return digest; 45 | } 46 | 47 | /// Base64解密 48 | static String decodeBase64(String data) { 49 | List bytes = base64Decode(data); 50 | String result = utf8.decode(bytes); 51 | return result; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /lib/util/image_util.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | 3 | import 'package:flutter/widgets.dart'; 4 | 5 | 6 | /// Image Util. 7 | class ImageUtil { 8 | late ImageStreamListener _listener; 9 | late ImageStream _imageStream; 10 | 11 | /// get image width height,load error throw exception.(unit px) 12 | /// 获取图片宽高,加载错误会抛出异常.(单位 px) 13 | /// image 14 | /// url network 15 | /// local url , package 16 | Future getImageWH({ 17 | Image? image, 18 | String? url, 19 | String? localUrl, 20 | String? package, 21 | ImageConfiguration? configuration, 22 | }) { 23 | Completer completer = Completer(); 24 | _listener = ImageStreamListener( 25 | (ImageInfo info, bool synchronousCall) { 26 | _imageStream.removeListener(_listener); 27 | if (!completer.isCompleted) { 28 | completer.complete(Rect.fromLTWH( 29 | 0, 0, info.image.width.toDouble(), info.image.height.toDouble())); 30 | } 31 | }, 32 | onError: (dynamic exception, StackTrace? stackTrace) { 33 | _imageStream.removeListener(_listener); 34 | if (!completer.isCompleted) { 35 | completer.completeError(exception, stackTrace); 36 | } 37 | }, 38 | ); 39 | 40 | if (image == null && 41 | (url == null || url.isEmpty) && 42 | (localUrl == null || localUrl.isEmpty)) { 43 | return Future.value(Rect.zero); 44 | } 45 | Image? img = image; 46 | img ??= (url != null && url.isNotEmpty) 47 | ? Image.network(url) 48 | : Image.asset(localUrl!, package: package); 49 | _imageStream = img.image.resolve(configuration ?? ImageConfiguration()); 50 | _imageStream.addListener(_listener); 51 | return completer.future; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /lib/util/json_util.dart: -------------------------------------------------------------------------------- 1 | import 'dart:convert'; 2 | 3 | /// Json Util. 4 | class JsonUtil { 5 | /// Converts object [value] to a JSON string. 6 | static String? encodeObj(dynamic value) { 7 | return value == null ? null : json.encode(value); 8 | } 9 | 10 | /// Converts JSON string [source] to object. 11 | static T? getObj(String? source, T Function(Map v) f) { 12 | if (source == null || source.isEmpty) return null; 13 | try { 14 | Map map = json.decode(source); 15 | return f(map); 16 | } catch (e) { 17 | print('JsonUtil convert error, Exception:${e.toString()}'); 18 | } 19 | return null; 20 | } 21 | 22 | /// Converts JSON string or JSON map [source] to object. 23 | static T? getObject(dynamic source, T Function(Map v) f) { 24 | if (source == null || source.toString().isEmpty) return null; 25 | try { 26 | Map map; 27 | if (source is String) { 28 | map = json.decode(source); 29 | } else { 30 | map = source; 31 | } 32 | return f(map); 33 | } catch (e) { 34 | print('JsonUtil convert error, Exception:${e.toString()}'); 35 | } 36 | return null; 37 | } 38 | 39 | /// Converts JSON string list [source] to object list. 40 | static List? getObjList(String? source, T Function(Map v) f) { 41 | if (source == null || source.isEmpty) return null; 42 | try { 43 | List list = json.decode(source); 44 | return list.map((value) { 45 | if (value is String) { 46 | value = json.decode(value); 47 | } 48 | return f(value); 49 | }).toList(); 50 | } catch (e) { 51 | print('JsonUtil convert error, Exception:${e.toString()}'); 52 | } 53 | return null; 54 | } 55 | 56 | /// Converts JSON string or JSON map list [source] to object list. 57 | static List? getObjectList(dynamic source, T Function(Map v) f) { 58 | if (source == null || source.toString().isEmpty) return null; 59 | try { 60 | List list; 61 | if (source is String) { 62 | list = json.decode(source); 63 | } else { 64 | list = source; 65 | } 66 | return list.map((value) { 67 | if (value is String) { 68 | value = json.decode(value); 69 | } 70 | return f(value); 71 | }).toList(); 72 | } catch (e) { 73 | print('JsonUtil convert error, Exception:${e.toString()}'); 74 | } 75 | return null; 76 | } 77 | 78 | /// get List 79 | /// [1, 2, 3, 4, 5, 6]; 80 | /// "[\"tom\",\"tony\",\"jacky\"]"; 81 | static List? getList(dynamic source) { 82 | List? list; 83 | if (source is String) { 84 | list = json.decode(source); 85 | } else { 86 | list = source; 87 | } 88 | return list?.map((v) { 89 | return v as T; 90 | }).toList(); 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /lib/util/keyboard_util.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/cupertino.dart'; 2 | import 'package:flutter/services.dart'; 3 | 4 | /// 软键盘相关工具类 5 | class KeyboardUtils { 6 | ///隐藏软键盘 7 | ///[context] 上下文 8 | static hideKeyboard(BuildContext context) { 9 | FocusManager.instance.primaryFocus?.unfocus(); 10 | } 11 | 12 | /// 隐藏键盘 13 | static void hide({Function? func}) { 14 | SystemChannels.textInput.invokeMethod('TextInput.hide').whenComplete(() { 15 | Future.delayed(const Duration(milliseconds: 10)).whenComplete(() { 16 | if (func != null) func(); 17 | }); 18 | }); 19 | } 20 | 21 | /// 显示键盘 22 | static void show({Function? func}) { 23 | SystemChannels.textInput.invokeMethod('TextInput.show').whenComplete(() { 24 | Future.delayed(const Duration(milliseconds: 10)).whenComplete(() { 25 | if (func != null) func(); 26 | }); 27 | }); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /lib/util/locale_util.dart: -------------------------------------------------------------------------------- 1 | import 'dart:ui'; 2 | 3 | import 'package:flutter/cupertino.dart'; 4 | import 'package:flutter_project/model/language.dart'; 5 | import 'package:flutter_project/util/logger_util.dart'; 6 | import 'package:flutter_project/util/sp_util.dart'; 7 | import 'package:get/get.dart'; 8 | 9 | /// 语言工具类 10 | class LocaleOptions { 11 | ///更新语言 12 | static updateLocale(Language language) { 13 | Locale? locale; 14 | SpUtil.updateLanguage(language); 15 | if (language.language == '' || language.country == '') { 16 | locale = Get.deviceLocale; 17 | } else { 18 | locale = Locale(language.language, language.country); 19 | } 20 | if (locale != null) { 21 | Get.updateLocale(locale); 22 | } 23 | } 24 | 25 | ///获取当前存储的默认语言 26 | static Locale getDefault() { 27 | var language = SpUtil.getLanguage(); 28 | if (language == null || language.language == '' || language.country == '') { 29 | Log().d('当前语言或者地区为空'); 30 | var local = Get.deviceLocale; 31 | var localLanguage = languageList 32 | .firstWhereOrNull((e) => e.language == local?.languageCode); 33 | if (localLanguage != null) { 34 | Log().d('加载具体的语言: ${localLanguage.country}, ${localLanguage.language}'); 35 | SpUtil.updateLanguage(localLanguage); 36 | return Locale(localLanguage.language, localLanguage.country); 37 | } else { 38 | Log().d('加载默认的语言'); 39 | SpUtil.updateLanguage(defLanguage); 40 | return Locale(defLanguage.language, defLanguage.country); 41 | } 42 | } else { 43 | return Locale(language.language, language.country); 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /lib/util/log_util.dart: -------------------------------------------------------------------------------- 1 | import 'dart:developer'; 2 | 3 | /** 4 | * @Author: Sky24n 5 | * @GitHub: https://github.com/Sky24n 6 | * @Description: Log Util. 7 | * @Date: 2018/9/29 8 | */ 9 | 10 | /// Log Util. 11 | class LogUtil { 12 | static const String _defTag = 'common_utils'; 13 | static bool _debugMode = false; //是否是debug模式,true: log v 不输出. 14 | static int _maxLen = 128; 15 | static String _tagValue = _defTag; 16 | 17 | static void init({ 18 | String tag = _defTag, 19 | bool isDebug = false, 20 | int maxLen = 128, 21 | }) { 22 | _tagValue = tag; 23 | _debugMode = isDebug; 24 | _maxLen = maxLen; 25 | } 26 | 27 | static void d(Object? object, {String? tag}) { 28 | if (_debugMode) { 29 | log('$tag d | ${object?.toString()}'); 30 | } 31 | } 32 | 33 | static void e(Object? object, {String? tag}) { 34 | _printLog(tag, ' e ', object); 35 | } 36 | 37 | static void v(Object? object, {String? tag}) { 38 | if (_debugMode) { 39 | _printLog(tag, ' v ', object); 40 | } 41 | } 42 | 43 | static void _printLog(String? tag, String stag, Object? object) { 44 | String da = object?.toString() ?? 'null'; 45 | tag = tag ?? _tagValue; 46 | if (da.length <= _maxLen) { 47 | print('$tag$stag $da'); 48 | return; 49 | } 50 | print( 51 | '$tag$stag — — — — — — — — — — — — — — — — st — — — — — — — — — — — — — — — —'); 52 | while (da.isNotEmpty) { 53 | if (da.length > _maxLen) { 54 | print('$tag$stag| ${da.substring(0, _maxLen)}'); 55 | da = da.substring(_maxLen, da.length); 56 | } else { 57 | print('$tag$stag| $da'); 58 | da = ''; 59 | } 60 | } 61 | print( 62 | '$tag$stag — — — — — — — — — — — — — — — — ed — — — — — — — — — — — — — — — —'); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /lib/util/num_util.dart: -------------------------------------------------------------------------------- 1 | 2 | import 'package:decimal/decimal.dart'; 3 | import 'package:rational/rational.dart'; 4 | 5 | /// Num Util. 6 | class NumUtil { 7 | /// The parameter [fractionDigits] must be an integer satisfying: `0 <= fractionDigits <= 20`. 8 | static num? getNumByValueStr(String valueStr, {int? fractionDigits}) { 9 | double? value = double.tryParse(valueStr); 10 | return fractionDigits == null 11 | ? value 12 | : getNumByValueDouble(value, fractionDigits); 13 | } 14 | 15 | /// The parameter [fractionDigits] must be an integer satisfying: `0 <= fractionDigits <= 20`. 16 | static num? getNumByValueDouble(double? value, int fractionDigits) { 17 | if (value == null) return null; 18 | String valueStr = value.toStringAsFixed(fractionDigits); 19 | return fractionDigits == 0 20 | ? int.tryParse(valueStr) 21 | : double.tryParse(valueStr); 22 | } 23 | 24 | /// get int by value str. 25 | static int? getIntByValueStr(String valueStr, {int? defValue = 0}) { 26 | return int.tryParse(valueStr) ?? defValue; 27 | } 28 | 29 | /// get double by value str. 30 | static double? getDoubleByValueStr(String valueStr, {double? defValue = 0}) { 31 | return double.tryParse(valueStr) ?? defValue; 32 | } 33 | 34 | ///isZero 35 | static bool isZero(num? value) { 36 | return value == null || value == 0; 37 | } 38 | 39 | /// 加 (精确相加,防止精度丢失). 40 | static double add(num a, num b) { 41 | return addDec(a, b).toDouble(); 42 | } 43 | 44 | /// 减 (精确相减,防止精度丢失). 45 | static double subtract(num a, num b) { 46 | return subtractDec(a, b).toDouble(); 47 | } 48 | 49 | /// 乘 (精确相乘,防止精度丢失). 50 | static double multiply(num a, num b) { 51 | return multiplyDec(a, b).toDouble(); 52 | } 53 | 54 | /// 除 (精确相除,防止精度丢失). 55 | static double divide(num a, num b) { 56 | return divideDec(a, b).toDouble(); 57 | } 58 | 59 | /// 加 (精确相加,防止精度丢失). 60 | static Decimal addDec(num a, num b) { 61 | return addDecStr(a.toString(), b.toString()); 62 | } 63 | 64 | /// 减 (精确相减,防止精度丢失). 65 | static Decimal subtractDec(num a, num b) { 66 | return subtractDecStr(a.toString(), b.toString()); 67 | } 68 | 69 | /// 乘 (精确相乘,防止精度丢失). 70 | static Decimal multiplyDec(num a, num b) { 71 | return multiplyDecStr(a.toString(), b.toString()); 72 | } 73 | 74 | /// 除 (精确相除,防止精度丢失). 75 | static Decimal divideDec(num a, num b) { 76 | return divideDecStr(a.toString(), b.toString()); 77 | } 78 | 79 | /// 余数 80 | static Decimal remainder(num a, num b) { 81 | return remainderDecStr(a.toString(), b.toString()); 82 | } 83 | 84 | /// Relational less than operator. 85 | static bool lessThan(num a, num b) { 86 | return lessThanDecStr(a.toString(), b.toString()); 87 | } 88 | 89 | /// Relational less than or equal operator. 90 | static bool thanOrEqual(num a, num b) { 91 | return thanOrEqualDecStr(a.toString(), b.toString()); 92 | } 93 | 94 | /// Relational greater than operator. 95 | static bool greaterThan(num a, num b) { 96 | return greaterThanDecStr(a.toString(), b.toString()); 97 | } 98 | 99 | /// Relational greater than or equal operator. 100 | static bool greaterOrEqual(num a, num b) { 101 | return greaterOrEqualDecStr(a.toString(), b.toString()); 102 | } 103 | 104 | /// 加 105 | static Decimal addDecStr(String a, String b) { 106 | return Decimal.parse(a) + Decimal.parse(b); 107 | } 108 | 109 | /// 减 110 | static Decimal subtractDecStr(String a, String b) { 111 | return Decimal.parse(a) - Decimal.parse(b); 112 | } 113 | 114 | /// 乘 115 | static Decimal multiplyDecStr(String a, String b) { 116 | return Decimal.parse(a) * Decimal.parse(b); 117 | } 118 | 119 | /// 除 120 | static Decimal divideDecStr(String a, String b) { 121 | Rational value = Decimal.parse(a) / Decimal.parse(b); 122 | return value.toDecimal(); 123 | } 124 | 125 | /// 余数 126 | static Decimal remainderDecStr(String a, String b) { 127 | return Decimal.parse(a) % Decimal.parse(b); 128 | } 129 | 130 | /// Relational less than operator. 131 | static bool lessThanDecStr(String a, String b) { 132 | return Decimal.parse(a) < Decimal.parse(b); 133 | } 134 | 135 | /// Relational less than or equal operator. 136 | static bool thanOrEqualDecStr(String a, String b) { 137 | return Decimal.parse(a) <= Decimal.parse(b); 138 | } 139 | 140 | /// Relational greater than operator. 141 | static bool greaterThanDecStr(String a, String b) { 142 | return Decimal.parse(a) > Decimal.parse(b); 143 | } 144 | 145 | /// Relational greater than or equal operator. 146 | static bool greaterOrEqualDecStr(String a, String b) { 147 | return Decimal.parse(a) >= Decimal.parse(b); 148 | } 149 | } 150 | -------------------------------------------------------------------------------- /lib/util/screen_util.dart: -------------------------------------------------------------------------------- 1 | import 'dart:io'; 2 | 3 | import 'package:flutter/material.dart'; 4 | import 'package:flutter/services.dart'; 5 | 6 | /// 屏幕适配工具类 7 | class ScreenUtils { 8 | ///去除状态栏半透明 9 | static setSystemTransparent() { 10 | if (Platform.isAndroid) { 11 | SystemUiOverlayStyle style = const SystemUiOverlayStyle( 12 | statusBarColor: Colors.transparent, 13 | statusBarIconBrightness: Brightness.dark, 14 | statusBarBrightness: Brightness.dark, 15 | ); 16 | SystemChrome.setSystemUIOverlayStyle(style); 17 | } 18 | } 19 | 20 | static setSystemStatusBarColor({ 21 | Color? statusBarColor, 22 | Brightness? statusBarIconBrightness, 23 | Brightness? statusBarBrightness, 24 | }) { 25 | if (Platform.isAndroid) { 26 | SystemUiOverlayStyle style = SystemUiOverlayStyle( 27 | statusBarColor: statusBarColor ?? Colors.transparent, 28 | statusBarIconBrightness: statusBarIconBrightness ?? Brightness.dark, 29 | statusBarBrightness: statusBarBrightness ?? Brightness.light, 30 | ); 31 | SystemChrome.setSystemUIOverlayStyle(style); 32 | } 33 | } 34 | 35 | /// 强制竖屏 36 | static setPreferredOrientation() { 37 | SystemChrome.setPreferredOrientations([ 38 | DeviceOrientation.portraitUp, 39 | DeviceOrientation.portraitDown, 40 | ]); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /lib/util/sp_key.dart: -------------------------------------------------------------------------------- 1 | /// 键值对 key 2 | class SPKey{ 3 | static const String language = 'language'; 4 | static const String token = 'token'; 5 | static const String isFirstOpen = 'isFirstOpen'; 6 | } -------------------------------------------------------------------------------- /lib/util/sp_util.dart: -------------------------------------------------------------------------------- 1 | import 'dart:convert'; 2 | 3 | import 'package:flutter_project/model/language.dart'; 4 | import 'package:flutter_project/util/logger_util.dart'; 5 | import 'package:flutter_project/util/sp_key.dart'; 6 | import 'package:get/get.dart'; 7 | import 'package:shared_preferences/shared_preferences.dart'; 8 | 9 | /// 键值对存储 10 | class SpUtil { 11 | ///是否第一次打开 12 | static bool isFirstOpen() { 13 | SharedPreferences sp = Get.find(); 14 | return sp.getBool(SPKey.isFirstOpen) ?? true; 15 | } 16 | 17 | /// 已打开APP 18 | static Future appIsOpen() { 19 | return Get.find().setBool(SPKey.isFirstOpen, false); 20 | } 21 | 22 | ///Token 23 | static String getToken() { 24 | SharedPreferences sp = Get.find(); 25 | return sp.getString(SPKey.token) ?? ""; 26 | } 27 | 28 | /// Token 29 | static Future setToken(String token) { 30 | return Get.find().setString(SPKey.token, token); 31 | } 32 | 33 | ///存储语言 34 | ///[Language] 语言 35 | static updateLanguage(Language language) { 36 | Get.find() 37 | .setString(SPKey.language, jsonEncode(language.toJson())); 38 | } 39 | 40 | ///获取语言选项 41 | ///[Language] 语言 42 | static Language? getLanguage() { 43 | SharedPreferences sp = Get.find(); 44 | try { 45 | var json = sp.getString(SPKey.language); 46 | if (json == null) { 47 | return null; 48 | } else { 49 | return Language.fromJson(jsonDecode(json)); 50 | } 51 | } on Exception catch (e) { 52 | Log().d(e.toString()); 53 | return null; 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /lib/util/text_util.dart: -------------------------------------------------------------------------------- 1 | /// Text Util. 2 | class TextUtil { 3 | /// isEmpty 4 | static bool isEmpty(String? text) { 5 | return text == null || text.isEmpty; 6 | } 7 | 8 | /// 每隔 x位 加 pattern 9 | static String formatDigitPattern(String text, 10 | {int digit = 4, String pattern = ' '}) { 11 | text = text.replaceAllMapped(RegExp('(.{$digit})'), (Match match) { 12 | return '${match.group(0)}$pattern'; 13 | }); 14 | if (text.endsWith(pattern)) { 15 | text = text.substring(0, text.length - 1); 16 | } 17 | return text; 18 | } 19 | 20 | /// 每隔 x位 加 pattern, 从末尾开始 21 | static String formatDigitPatternEnd(String text, 22 | {int digit = 4, String pattern = ' '}) { 23 | String temp = reverse(text); 24 | temp = formatDigitPattern(temp, digit: digit, pattern: pattern); 25 | temp = reverse(temp); 26 | return temp; 27 | } 28 | 29 | /// 每隔4位加空格 30 | static String formatSpace4(String text) { 31 | return formatDigitPattern(text); 32 | } 33 | 34 | /// 每隔3三位加逗号 35 | /// num 数字或数字字符串。int型。 36 | static String formatComma3(Object num) { 37 | return formatDigitPatternEnd(num.toString(), digit: 3, pattern: ','); 38 | } 39 | 40 | /// 每隔3三位加逗号 41 | /// num 数字或数字字符串。double型。 42 | static String formatDoubleComma3(Object num, 43 | {int digit = 3, String pattern = ','}) { 44 | List list = num.toString().split('.'); 45 | String left = 46 | formatDigitPatternEnd(list[0], digit: digit, pattern: pattern); 47 | String right = list[1]; 48 | return '$left.$right'; 49 | } 50 | 51 | /// hideNumber 52 | static String hideNumber(String phoneNo, 53 | {int start = 3, int end = 7, String replacement = '****'}) { 54 | return phoneNo.replaceRange(start, end, replacement); 55 | } 56 | 57 | /// replace 58 | static String replace(String text, Pattern from, String replace) { 59 | return text.replaceAll(from, replace); 60 | } 61 | 62 | /// split 63 | static List split(String text, Pattern pattern) { 64 | return text.split(pattern); 65 | } 66 | 67 | /// reverse 68 | static String reverse(String text) { 69 | if (isEmpty(text)) return ''; 70 | StringBuffer sb = StringBuffer(); 71 | for (int i = text.length - 1; i >= 0; i--) { 72 | sb.writeCharCode(text.codeUnitAt(i)); 73 | } 74 | return sb.toString(); 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /lib/util/timer_util.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | 3 | ///timer callback.(millisUntilFinished 毫秒). 4 | typedef OnTimerTickCallback = void Function(int millisUntilFinished); 5 | 6 | /// TimerUtil. 7 | class TimerUtil { 8 | TimerUtil({ 9 | this.mInterval = Duration.millisecondsPerSecond, 10 | this.mTotalTime = 0, 11 | }); 12 | 13 | /// Timer. 14 | Timer? _mTimer; 15 | 16 | /// Timer是否启动. 17 | bool _isActive = false; 18 | 19 | /// Timer间隔 单位毫秒,默认1000毫秒(1秒). 20 | int mInterval; 21 | 22 | /// 倒计时总时间 23 | int mTotalTime; //单位毫秒 24 | 25 | OnTimerTickCallback? _onTimerTickCallback; 26 | 27 | /// 设置Timer间隔. 28 | void setInterval(int interval) { 29 | if (interval <= 0) interval = Duration.millisecondsPerSecond; 30 | mInterval = interval; 31 | } 32 | 33 | /// 设置倒计时总时间. 34 | void setTotalTime(int totalTime) { 35 | if (totalTime <= 0) return; 36 | mTotalTime = totalTime; 37 | } 38 | 39 | /// 启动定时Timer. 40 | void startTimer() { 41 | if (_isActive || mInterval <= 0) return; 42 | _isActive = true; 43 | Duration duration = Duration(milliseconds: mInterval); 44 | _doCallback(0); 45 | _mTimer = Timer.periodic(duration, (Timer timer) { 46 | _doCallback(timer.tick); 47 | }); 48 | } 49 | 50 | /// 启动倒计时Timer. 51 | void startCountDown() { 52 | if (_isActive || mInterval <= 0 || mTotalTime <= 0) return; 53 | _isActive = true; 54 | Duration duration = Duration(milliseconds: mInterval); 55 | _doCallback(mTotalTime); 56 | _mTimer = Timer.periodic(duration, (Timer timer) { 57 | int time = mTotalTime - mInterval; 58 | mTotalTime = time; 59 | if (time >= mInterval) { 60 | _doCallback(time); 61 | } else if (time == 0) { 62 | _doCallback(time); 63 | cancel(); 64 | } else { 65 | timer.cancel(); 66 | Future.delayed(Duration(milliseconds: time), () { 67 | mTotalTime = 0; 68 | _doCallback(0); 69 | cancel(); 70 | }); 71 | } 72 | }); 73 | } 74 | 75 | void _doCallback(int time) { 76 | if (_onTimerTickCallback != null) { 77 | _onTimerTickCallback!(time); 78 | } 79 | } 80 | 81 | /// 重设倒计时总时间. 82 | void updateTotalTime(int totalTime) { 83 | cancel(); 84 | mTotalTime = totalTime; 85 | startCountDown(); 86 | } 87 | 88 | /// Timer是否启动. 89 | bool isActive() { 90 | return _isActive; 91 | } 92 | 93 | /// 取消计时器. 94 | void cancel() { 95 | _mTimer?.cancel(); 96 | _mTimer = null; 97 | _isActive = false; 98 | } 99 | 100 | /// set timer callback. 101 | void setOnTimerTickCallback(OnTimerTickCallback callback) { 102 | _onTimerTickCallback = callback; 103 | } 104 | } 105 | -------------------------------------------------------------------------------- /lib/util/toast_util.dart: -------------------------------------------------------------------------------- 1 | import 'package:fluttertoast/fluttertoast.dart'; 2 | 3 | class ToastUtil{ 4 | static void show({required String msg}){ 5 | Fluttertoast.showToast(msg: msg); 6 | } 7 | } -------------------------------------------------------------------------------- /lib/util/user_util.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_project/util/sp_util.dart'; 2 | 3 | class UserUtil { 4 | 5 | /// 是否登录 6 | static bool isLogin() { 7 | return SpUtil.getToken().isNotEmpty; 8 | } 9 | 10 | 11 | static void setToken({required String token}){ 12 | SpUtil.setToken(token); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /lib/widgets/bottom_bar_item.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter/services.dart'; 3 | import 'package:flutter_project/res/colors/color_res.dart'; 4 | import 'package:flutter_screenutil/flutter_screenutil.dart'; 5 | 6 | /// BottomBarItem 7 | class BottomBarItem extends StatefulWidget { 8 | // Tab 名字 9 | final String tabName; 10 | 11 | // Tab 图标 12 | final String tabIcon; 13 | 14 | // Tab 选中图标 15 | final String tabSelectedIcon; 16 | 17 | // 默认颜色 18 | final Color tabTextColor; 19 | 20 | // 选中颜色 21 | final Color tabTextSelectedColor; 22 | 23 | // Tab对应索引 24 | final int tabIndex; 25 | 26 | // 点击回调 27 | final Function(int) onTap; 28 | 29 | // 是否选中 30 | final bool isChecked; 31 | 32 | // 角标 33 | final int badger; 34 | 35 | const BottomBarItem({ 36 | Key? key, 37 | required this.tabName, 38 | required this.tabIcon, 39 | required this.tabSelectedIcon, 40 | required this.onTap, 41 | required this.tabIndex, 42 | this.tabTextColor = Colors.grey, 43 | this.tabTextSelectedColor = RC.themeColor, 44 | this.isChecked = false, 45 | this.badger = 0, 46 | }) : super(key: key); 47 | 48 | @override 49 | State createState() => _BottomBarItemState(); 50 | } 51 | 52 | class _BottomBarItemState extends State { 53 | @override 54 | Widget build(BuildContext context) { 55 | return InkWell( 56 | child: Stack( 57 | children: [ 58 | Positioned( 59 | child: Container( 60 | alignment: Alignment.center, 61 | child: Column( 62 | crossAxisAlignment: CrossAxisAlignment.center, 63 | mainAxisAlignment: MainAxisAlignment.start, 64 | children: [ 65 | widget.isChecked 66 | ? Image.asset( 67 | widget.tabSelectedIcon, 68 | bundle: PlatformAssetBundle(), 69 | width: 40.w, 70 | height: 30.w, 71 | ) 72 | : Image.asset( 73 | widget.tabIcon, 74 | width: 40.w, 75 | height: 30.w, 76 | ), 77 | Text( 78 | widget.tabName, 79 | style: TextStyle( 80 | color: widget.isChecked 81 | ? widget.tabTextSelectedColor 82 | : widget.tabTextColor, 83 | fontSize: 10.sp, 84 | ), 85 | ), 86 | ], 87 | ), 88 | ), 89 | ), 90 | Visibility( 91 | visible: widget.badger > 0, 92 | child: Positioned( 93 | right: 30.w, 94 | top: 10.w, 95 | child: ClipOval( 96 | child: Container( 97 | alignment: Alignment.center, 98 | color: Colors.red, 99 | width: 8, 100 | height: 8, 101 | ), 102 | ), 103 | ), 104 | ) 105 | ], 106 | ), 107 | onTap: () { 108 | widget.onTap(widget.tabIndex); 109 | setState(() {}); 110 | }, 111 | ); 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /lib/widgets/lottie_bottom_bar_item.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_screenutil/flutter_screenutil.dart'; 3 | import 'package:lottie/lottie.dart'; 4 | 5 | /// Lottie BottomBarItem 6 | class LottieBottomBarItem extends StatefulWidget { 7 | // Tab 名字 8 | final String tabName; 9 | 10 | // Tab 图标 11 | final String tabIcon; 12 | 13 | // 默认颜色 14 | final Color tabTextColor; 15 | 16 | // 选中颜色 17 | final Color tabTextSelectedColor; 18 | 19 | // Tab对应索引 20 | final int tabIndex; 21 | 22 | // 点击回调 23 | final Function(int) onTap; 24 | 25 | // 是否选中 26 | final bool isChecked; 27 | 28 | // 角标 29 | final int badger; 30 | 31 | const LottieBottomBarItem({ 32 | Key? key, 33 | required this.tabName, 34 | required this.tabIcon, 35 | required this.onTap, 36 | required this.tabIndex, 37 | this.tabTextColor = Colors.grey, 38 | this.tabTextSelectedColor = Colors.black, 39 | this.isChecked = false, 40 | this.badger = 0, 41 | }) : super(key: key); 42 | 43 | @override 44 | State createState() => _BottomBarItemState(); 45 | } 46 | 47 | class _BottomBarItemState extends State 48 | with TickerProviderStateMixin { 49 | AnimationController? _animationController; 50 | 51 | @override 52 | void initState() { 53 | super.initState(); 54 | _animationController = AnimationController( 55 | vsync: this, duration: const Duration(milliseconds: 500)); 56 | if (widget.isChecked) { 57 | _animationController?.forward(); 58 | } 59 | } 60 | 61 | @override 62 | void didUpdateWidget(covariant LottieBottomBarItem oldWidget) { 63 | super.didUpdateWidget(oldWidget); 64 | if (!widget.isChecked && oldWidget != widget) { 65 | _animationController?.reset(); 66 | } 67 | } 68 | 69 | @override 70 | void dispose() { 71 | _animationController?.dispose(); 72 | super.dispose(); 73 | } 74 | 75 | @override 76 | Widget build(BuildContext context) { 77 | return InkWell( 78 | child: Stack( 79 | alignment: Alignment.bottomCenter, 80 | children: [ 81 | Positioned( 82 | child: Column( 83 | children: [ 84 | Lottie.asset( 85 | widget.tabIcon, 86 | repeat: false, 87 | controller: _animationController, 88 | width: 35.w, 89 | height: 30.w, 90 | ), 91 | Text( 92 | widget.tabName, 93 | style: TextStyle( 94 | color: widget.isChecked 95 | ? widget.tabTextSelectedColor 96 | : widget.tabTextColor, 97 | fontSize: 12.sp, 98 | ), 99 | ) 100 | ], 101 | ), 102 | ), 103 | Visibility( 104 | visible: widget.badger > 0, 105 | child: Positioned( 106 | right: 30.w, 107 | top: 10.w, 108 | child: ClipOval( 109 | child: Container( 110 | alignment: Alignment.center, 111 | color: Colors.red, 112 | width: 8, 113 | height: 8, 114 | ), 115 | ), 116 | ), 117 | ) 118 | ], 119 | ), 120 | onTap: () { 121 | widget.onTap(widget.tabIndex); 122 | _animationController?.forward(); 123 | }, 124 | ); 125 | } 126 | } 127 | -------------------------------------------------------------------------------- /lib/widgets/my_app_bar.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | ///自定义AppBar 4 | class MyAppBar extends AppBar { 5 | MyAppBar({ 6 | Key? key, 7 | String? title, 8 | Color? backgroundColor, 9 | Color? titleColor, 10 | VoidCallback? onBack, 11 | List? actions, 12 | }) : super( 13 | key: key, 14 | centerTitle: true, 15 | backgroundColor: backgroundColor ?? Colors.white, 16 | elevation: 0, 17 | actions: actions, 18 | title: Text( 19 | title ?? "", 20 | style: TextStyle( 21 | color: titleColor ?? Colors.black, 22 | fontWeight: FontWeight.bold, 23 | ), 24 | ), 25 | leading: onBack == null 26 | ? Container() 27 | : IconButton( 28 | icon: Icon( 29 | Icons.arrow_back_ios, 30 | color: titleColor ?? Colors.black, 31 | ), 32 | onPressed: () { 33 | onBack.call(); 34 | }, 35 | ), 36 | ); 37 | } 38 | -------------------------------------------------------------------------------- /linux/.gitignore: -------------------------------------------------------------------------------- 1 | flutter/ephemeral 2 | -------------------------------------------------------------------------------- /linux/flutter/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # This file controls Flutter-level build steps. It should not be edited. 2 | cmake_minimum_required(VERSION 3.10) 3 | 4 | set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") 5 | 6 | # Configuration provided via flutter tool. 7 | include(${EPHEMERAL_DIR}/generated_config.cmake) 8 | 9 | # TODO: Move the rest of this into files in ephemeral. See 10 | # https://github.com/flutter/flutter/issues/57146. 11 | 12 | # Serves the same purpose as list(TRANSFORM ... PREPEND ...), 13 | # which isn't available in 3.10. 14 | function(list_prepend LIST_NAME PREFIX) 15 | set(NEW_LIST "") 16 | foreach(element ${${LIST_NAME}}) 17 | list(APPEND NEW_LIST "${PREFIX}${element}") 18 | endforeach(element) 19 | set(${LIST_NAME} "${NEW_LIST}" PARENT_SCOPE) 20 | endfunction() 21 | 22 | # === Flutter Library === 23 | # System-level dependencies. 24 | find_package(PkgConfig REQUIRED) 25 | pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) 26 | pkg_check_modules(GLIB REQUIRED IMPORTED_TARGET glib-2.0) 27 | pkg_check_modules(GIO REQUIRED IMPORTED_TARGET gio-2.0) 28 | 29 | set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/libflutter_linux_gtk.so") 30 | 31 | # Published to parent scope for install step. 32 | set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) 33 | set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) 34 | set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) 35 | set(AOT_LIBRARY "${PROJECT_DIR}/build/lib/libapp.so" PARENT_SCOPE) 36 | 37 | list(APPEND FLUTTER_LIBRARY_HEADERS 38 | "fl_basic_message_channel.h" 39 | "fl_binary_codec.h" 40 | "fl_binary_messenger.h" 41 | "fl_dart_project.h" 42 | "fl_engine.h" 43 | "fl_json_message_codec.h" 44 | "fl_json_method_codec.h" 45 | "fl_message_codec.h" 46 | "fl_method_call.h" 47 | "fl_method_channel.h" 48 | "fl_method_codec.h" 49 | "fl_method_response.h" 50 | "fl_plugin_registrar.h" 51 | "fl_plugin_registry.h" 52 | "fl_standard_message_codec.h" 53 | "fl_standard_method_codec.h" 54 | "fl_string_codec.h" 55 | "fl_value.h" 56 | "fl_view.h" 57 | "flutter_linux.h" 58 | ) 59 | list_prepend(FLUTTER_LIBRARY_HEADERS "${EPHEMERAL_DIR}/flutter_linux/") 60 | add_library(flutter INTERFACE) 61 | target_include_directories(flutter INTERFACE 62 | "${EPHEMERAL_DIR}" 63 | ) 64 | target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}") 65 | target_link_libraries(flutter INTERFACE 66 | PkgConfig::GTK 67 | PkgConfig::GLIB 68 | PkgConfig::GIO 69 | ) 70 | add_dependencies(flutter flutter_assemble) 71 | 72 | # === Flutter tool backend === 73 | # _phony_ is a non-existent file to force this command to run every time, 74 | # since currently there's no way to get a full input/output list from the 75 | # flutter tool. 76 | add_custom_command( 77 | OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} 78 | ${CMAKE_CURRENT_BINARY_DIR}/_phony_ 79 | COMMAND ${CMAKE_COMMAND} -E env 80 | ${FLUTTER_TOOL_ENVIRONMENT} 81 | "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.sh" 82 | ${FLUTTER_TARGET_PLATFORM} ${CMAKE_BUILD_TYPE} 83 | VERBATIM 84 | ) 85 | add_custom_target(flutter_assemble DEPENDS 86 | "${FLUTTER_LIBRARY}" 87 | ${FLUTTER_LIBRARY_HEADERS} 88 | ) 89 | -------------------------------------------------------------------------------- /linux/flutter/generated_plugin_registrant.cc: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #include "generated_plugin_registrant.h" 8 | 9 | 10 | void fl_register_plugins(FlPluginRegistry* registry) { 11 | } 12 | -------------------------------------------------------------------------------- /linux/flutter/generated_plugin_registrant.h: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #ifndef GENERATED_PLUGIN_REGISTRANT_ 8 | #define GENERATED_PLUGIN_REGISTRANT_ 9 | 10 | #include 11 | 12 | // Registers Flutter plugins. 13 | void fl_register_plugins(FlPluginRegistry* registry); 14 | 15 | #endif // GENERATED_PLUGIN_REGISTRANT_ 16 | -------------------------------------------------------------------------------- /linux/flutter/generated_plugins.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Generated file, do not edit. 3 | # 4 | 5 | list(APPEND FLUTTER_PLUGIN_LIST 6 | ) 7 | 8 | list(APPEND FLUTTER_FFI_PLUGIN_LIST 9 | ) 10 | 11 | set(PLUGIN_BUNDLED_LIBRARIES) 12 | 13 | foreach(plugin ${FLUTTER_PLUGIN_LIST}) 14 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/linux plugins/${plugin}) 15 | target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) 16 | list(APPEND PLUGIN_BUNDLED_LIBRARIES $) 17 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) 18 | endforeach(plugin) 19 | 20 | foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) 21 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/linux plugins/${ffi_plugin}) 22 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) 23 | endforeach(ffi_plugin) 24 | -------------------------------------------------------------------------------- /linux/main.cc: -------------------------------------------------------------------------------- 1 | #include "my_application.h" 2 | 3 | int main(int argc, char** argv) { 4 | g_autoptr(MyApplication) app = my_application_new(); 5 | return g_application_run(G_APPLICATION(app), argc, argv); 6 | } 7 | -------------------------------------------------------------------------------- /linux/my_application.cc: -------------------------------------------------------------------------------- 1 | #include "my_application.h" 2 | 3 | #include 4 | #ifdef GDK_WINDOWING_X11 5 | #include 6 | #endif 7 | 8 | #include "flutter/generated_plugin_registrant.h" 9 | 10 | struct _MyApplication { 11 | GtkApplication parent_instance; 12 | char** dart_entrypoint_arguments; 13 | }; 14 | 15 | G_DEFINE_TYPE(MyApplication, my_application, GTK_TYPE_APPLICATION) 16 | 17 | // Implements GApplication::activate. 18 | static void my_application_activate(GApplication* application) { 19 | MyApplication* self = MY_APPLICATION(application); 20 | GtkWindow* window = 21 | GTK_WINDOW(gtk_application_window_new(GTK_APPLICATION(application))); 22 | 23 | // Use a header bar when running in GNOME as this is the common style used 24 | // by applications and is the setup most users will be using (e.g. Ubuntu 25 | // desktop). 26 | // If running on X and not using GNOME then just use a traditional title bar 27 | // in case the window manager does more exotic layout, e.g. tiling. 28 | // If running on Wayland assume the header bar will work (may need changing 29 | // if future cases occur). 30 | gboolean use_header_bar = TRUE; 31 | #ifdef GDK_WINDOWING_X11 32 | GdkScreen* screen = gtk_window_get_screen(window); 33 | if (GDK_IS_X11_SCREEN(screen)) { 34 | const gchar* wm_name = gdk_x11_screen_get_window_manager_name(screen); 35 | if (g_strcmp0(wm_name, "GNOME Shell") != 0) { 36 | use_header_bar = FALSE; 37 | } 38 | } 39 | #endif 40 | if (use_header_bar) { 41 | GtkHeaderBar* header_bar = GTK_HEADER_BAR(gtk_header_bar_new()); 42 | gtk_widget_show(GTK_WIDGET(header_bar)); 43 | gtk_header_bar_set_title(header_bar, "flutter_project"); 44 | gtk_header_bar_set_show_close_button(header_bar, TRUE); 45 | gtk_window_set_titlebar(window, GTK_WIDGET(header_bar)); 46 | } else { 47 | gtk_window_set_title(window, "flutter_project"); 48 | } 49 | 50 | gtk_window_set_default_size(window, 1280, 720); 51 | gtk_widget_show(GTK_WIDGET(window)); 52 | 53 | g_autoptr(FlDartProject) project = fl_dart_project_new(); 54 | fl_dart_project_set_dart_entrypoint_arguments(project, self->dart_entrypoint_arguments); 55 | 56 | FlView* view = fl_view_new(project); 57 | gtk_widget_show(GTK_WIDGET(view)); 58 | gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(view)); 59 | 60 | fl_register_plugins(FL_PLUGIN_REGISTRY(view)); 61 | 62 | gtk_widget_grab_focus(GTK_WIDGET(view)); 63 | } 64 | 65 | // Implements GApplication::local_command_line. 66 | static gboolean my_application_local_command_line(GApplication* application, gchar*** arguments, int* exit_status) { 67 | MyApplication* self = MY_APPLICATION(application); 68 | // Strip out the first argument as it is the binary name. 69 | self->dart_entrypoint_arguments = g_strdupv(*arguments + 1); 70 | 71 | g_autoptr(GError) error = nullptr; 72 | if (!g_application_register(application, nullptr, &error)) { 73 | g_warning("Failed to register: %s", error->message); 74 | *exit_status = 1; 75 | return TRUE; 76 | } 77 | 78 | g_application_activate(application); 79 | *exit_status = 0; 80 | 81 | return TRUE; 82 | } 83 | 84 | // Implements GObject::dispose. 85 | static void my_application_dispose(GObject* object) { 86 | MyApplication* self = MY_APPLICATION(object); 87 | g_clear_pointer(&self->dart_entrypoint_arguments, g_strfreev); 88 | G_OBJECT_CLASS(my_application_parent_class)->dispose(object); 89 | } 90 | 91 | static void my_application_class_init(MyApplicationClass* klass) { 92 | G_APPLICATION_CLASS(klass)->activate = my_application_activate; 93 | G_APPLICATION_CLASS(klass)->local_command_line = my_application_local_command_line; 94 | G_OBJECT_CLASS(klass)->dispose = my_application_dispose; 95 | } 96 | 97 | static void my_application_init(MyApplication* self) {} 98 | 99 | MyApplication* my_application_new() { 100 | return MY_APPLICATION(g_object_new(my_application_get_type(), 101 | "application-id", APPLICATION_ID, 102 | "flags", G_APPLICATION_NON_UNIQUE, 103 | nullptr)); 104 | } 105 | -------------------------------------------------------------------------------- /linux/my_application.h: -------------------------------------------------------------------------------- 1 | #ifndef FLUTTER_MY_APPLICATION_H_ 2 | #define FLUTTER_MY_APPLICATION_H_ 3 | 4 | #include 5 | 6 | G_DECLARE_FINAL_TYPE(MyApplication, my_application, MY, APPLICATION, 7 | GtkApplication) 8 | 9 | /** 10 | * my_application_new: 11 | * 12 | * Creates a new Flutter-based application. 13 | * 14 | * Returns: a new #MyApplication. 15 | */ 16 | MyApplication* my_application_new(); 17 | 18 | #endif // FLUTTER_MY_APPLICATION_H_ 19 | -------------------------------------------------------------------------------- /macos/.gitignore: -------------------------------------------------------------------------------- 1 | # Flutter-related 2 | **/Flutter/ephemeral/ 3 | **/Pods/ 4 | 5 | # Xcode-related 6 | **/dgph 7 | **/xcuserdata/ 8 | -------------------------------------------------------------------------------- /macos/Flutter/Flutter-Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" 2 | #include "ephemeral/Flutter-Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /macos/Flutter/Flutter-Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" 2 | #include "ephemeral/Flutter-Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /macos/Flutter/GeneratedPluginRegistrant.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | import FlutterMacOS 6 | import Foundation 7 | 8 | import connectivity_macos 9 | import device_info_plus 10 | import package_info_plus 11 | import path_provider_foundation 12 | import shared_preferences_foundation 13 | import sqflite 14 | 15 | func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { 16 | ConnectivityPlugin.register(with: registry.registrar(forPlugin: "ConnectivityPlugin")) 17 | DeviceInfoPlusMacosPlugin.register(with: registry.registrar(forPlugin: "DeviceInfoPlusMacosPlugin")) 18 | FPPPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FPPPackageInfoPlusPlugin")) 19 | PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin")) 20 | SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin")) 21 | SqflitePlugin.register(with: registry.registrar(forPlugin: "SqflitePlugin")) 22 | } 23 | -------------------------------------------------------------------------------- /macos/Podfile: -------------------------------------------------------------------------------- 1 | platform :osx, '10.14' 2 | 3 | # CocoaPods analytics sends network stats synchronously affecting flutter build latency. 4 | ENV['COCOAPODS_DISABLE_STATS'] = 'true' 5 | 6 | project 'Runner', { 7 | 'Debug' => :debug, 8 | 'Profile' => :release, 9 | 'Release' => :release, 10 | } 11 | 12 | def flutter_root 13 | generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'ephemeral', 'Flutter-Generated.xcconfig'), __FILE__) 14 | unless File.exist?(generated_xcode_build_settings_path) 15 | raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure \"flutter pub get\" is executed first" 16 | end 17 | 18 | File.foreach(generated_xcode_build_settings_path) do |line| 19 | matches = line.match(/FLUTTER_ROOT\=(.*)/) 20 | return matches[1].strip if matches 21 | end 22 | raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Flutter-Generated.xcconfig, then run \"flutter pub get\"" 23 | end 24 | 25 | require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) 26 | 27 | flutter_macos_podfile_setup 28 | 29 | target 'Runner' do 30 | use_frameworks! 31 | use_modular_headers! 32 | 33 | flutter_install_all_macos_pods File.dirname(File.realpath(__FILE__)) 34 | target 'RunnerTests' do 35 | inherit! :search_paths 36 | end 37 | end 38 | 39 | post_install do |installer| 40 | installer.pods_project.targets.each do |target| 41 | flutter_additional_macos_build_settings(target) 42 | end 43 | end 44 | -------------------------------------------------------------------------------- /macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 37 | 38 | 39 | 40 | 41 | 42 | 52 | 54 | 60 | 61 | 62 | 63 | 69 | 71 | 77 | 78 | 79 | 80 | 82 | 83 | 86 | 87 | 88 | -------------------------------------------------------------------------------- /macos/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /macos/Runner/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | import Cocoa 2 | import FlutterMacOS 3 | 4 | @NSApplicationMain 5 | class AppDelegate: FlutterAppDelegate { 6 | override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool { 7 | return true 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "16x16", 5 | "idiom" : "mac", 6 | "filename" : "app_icon_16.png", 7 | "scale" : "1x" 8 | }, 9 | { 10 | "size" : "16x16", 11 | "idiom" : "mac", 12 | "filename" : "app_icon_32.png", 13 | "scale" : "2x" 14 | }, 15 | { 16 | "size" : "32x32", 17 | "idiom" : "mac", 18 | "filename" : "app_icon_32.png", 19 | "scale" : "1x" 20 | }, 21 | { 22 | "size" : "32x32", 23 | "idiom" : "mac", 24 | "filename" : "app_icon_64.png", 25 | "scale" : "2x" 26 | }, 27 | { 28 | "size" : "128x128", 29 | "idiom" : "mac", 30 | "filename" : "app_icon_128.png", 31 | "scale" : "1x" 32 | }, 33 | { 34 | "size" : "128x128", 35 | "idiom" : "mac", 36 | "filename" : "app_icon_256.png", 37 | "scale" : "2x" 38 | }, 39 | { 40 | "size" : "256x256", 41 | "idiom" : "mac", 42 | "filename" : "app_icon_256.png", 43 | "scale" : "1x" 44 | }, 45 | { 46 | "size" : "256x256", 47 | "idiom" : "mac", 48 | "filename" : "app_icon_512.png", 49 | "scale" : "2x" 50 | }, 51 | { 52 | "size" : "512x512", 53 | "idiom" : "mac", 54 | "filename" : "app_icon_512.png", 55 | "scale" : "1x" 56 | }, 57 | { 58 | "size" : "512x512", 59 | "idiom" : "mac", 60 | "filename" : "app_icon_1024.png", 61 | "scale" : "2x" 62 | } 63 | ], 64 | "info" : { 65 | "version" : 1, 66 | "author" : "xcode" 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yixiaolunhui/flutter_project/788a64a93395b3fb32aad400b87785f252a8c71b/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yixiaolunhui/flutter_project/788a64a93395b3fb32aad400b87785f252a8c71b/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yixiaolunhui/flutter_project/788a64a93395b3fb32aad400b87785f252a8c71b/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yixiaolunhui/flutter_project/788a64a93395b3fb32aad400b87785f252a8c71b/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yixiaolunhui/flutter_project/788a64a93395b3fb32aad400b87785f252a8c71b/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yixiaolunhui/flutter_project/788a64a93395b3fb32aad400b87785f252a8c71b/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yixiaolunhui/flutter_project/788a64a93395b3fb32aad400b87785f252a8c71b/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png -------------------------------------------------------------------------------- /macos/Runner/Configs/AppInfo.xcconfig: -------------------------------------------------------------------------------- 1 | // Application-level settings for the Runner target. 2 | // 3 | // This may be replaced with something auto-generated from metadata (e.g., pubspec.yaml) in the 4 | // future. If not, the values below would default to using the project name when this becomes a 5 | // 'flutter create' template. 6 | 7 | // The application's name. By default this is also the title of the Flutter window. 8 | PRODUCT_NAME = flutter_project 9 | 10 | // The application's bundle identifier 11 | PRODUCT_BUNDLE_IDENTIFIER = com.project.flutterProject 12 | 13 | // The copyright displayed in application information 14 | PRODUCT_COPYRIGHT = Copyright © 2024 com.project. All rights reserved. 15 | -------------------------------------------------------------------------------- /macos/Runner/Configs/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include "../../Flutter/Flutter-Debug.xcconfig" 2 | #include "Warnings.xcconfig" 3 | -------------------------------------------------------------------------------- /macos/Runner/Configs/Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include "../../Flutter/Flutter-Release.xcconfig" 2 | #include "Warnings.xcconfig" 3 | -------------------------------------------------------------------------------- /macos/Runner/Configs/Warnings.xcconfig: -------------------------------------------------------------------------------- 1 | WARNING_CFLAGS = -Wall -Wconditional-uninitialized -Wnullable-to-nonnull-conversion -Wmissing-method-return-type -Woverlength-strings 2 | GCC_WARN_UNDECLARED_SELECTOR = YES 3 | CLANG_UNDEFINED_BEHAVIOR_SANITIZER_NULLABILITY = YES 4 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE 5 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES 6 | CLANG_WARN_PRAGMA_PACK = YES 7 | CLANG_WARN_STRICT_PROTOTYPES = YES 8 | CLANG_WARN_COMMA = YES 9 | GCC_WARN_STRICT_SELECTOR_MATCH = YES 10 | CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES 11 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES 12 | GCC_WARN_SHADOW = YES 13 | CLANG_WARN_UNREACHABLE_CODE = YES 14 | -------------------------------------------------------------------------------- /macos/Runner/DebugProfile.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.security.app-sandbox 6 | 7 | com.apple.security.cs.allow-jit 8 | 9 | com.apple.security.network.server 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /macos/Runner/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | $(FLUTTER_BUILD_NAME) 21 | CFBundleVersion 22 | $(FLUTTER_BUILD_NUMBER) 23 | LSMinimumSystemVersion 24 | $(MACOSX_DEPLOYMENT_TARGET) 25 | NSHumanReadableCopyright 26 | $(PRODUCT_COPYRIGHT) 27 | NSMainNibFile 28 | MainMenu 29 | NSPrincipalClass 30 | NSApplication 31 | 32 | 33 | -------------------------------------------------------------------------------- /macos/Runner/MainFlutterWindow.swift: -------------------------------------------------------------------------------- 1 | import Cocoa 2 | import FlutterMacOS 3 | 4 | class MainFlutterWindow: NSWindow { 5 | override func awakeFromNib() { 6 | let flutterViewController = FlutterViewController.init() 7 | let windowFrame = self.frame 8 | self.contentViewController = flutterViewController 9 | self.setFrame(windowFrame, display: true) 10 | 11 | RegisterGeneratedPlugins(registry: flutterViewController) 12 | 13 | super.awakeFromNib() 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /macos/Runner/Release.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.security.app-sandbox 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /res_build.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # 定义资源目录和输出目录 4 | resourcesDir="assets/images" 5 | outputDir="lib/res/images" 6 | 7 | # 切换到资源目录,获取资源数量和数据 8 | cd "$resourcesDir" || exit 9 | resCount=$(find ./* | wc -l | sed -e 's/^[[:space:]]*//') 10 | resources=$(ls) 11 | 12 | # 切换到输出目录 13 | cd ../.. 14 | cd "$outputDir" || exit 15 | 16 | # 遍历资源文件并汇总资源名集合 17 | declare -a resNames 18 | for resource in $resources; do 19 | resNames+=("$resource") 20 | done 21 | 22 | # 创建资源r文件 23 | progress=1 24 | # 删除r文件 25 | rm -f r.dart 26 | # 类名写入r文件 27 | echo 'class R {' >>r.dart 28 | # 循环申明常量写入r文件 29 | for resName in "${resNames[@]}"; do 30 | nameSlices=($(echo "$resName" | tr '_' ' ' | tr '.' ' ')) 31 | str="" 32 | for slice in "${nameSlices[@]}"; do 33 | str+="${slice}_" 34 | done 35 | resConstant="${str%?}" 36 | echo -ne "${progress}/${resCount}:${resName} \r" 37 | printf " static const String %s = '%s/%s';\n" "$resConstant" "$resourcesDir" "$resName" >>r.dart 38 | progress=$((progress + 1)) 39 | done 40 | echo '}' >>r.dart 41 | 42 | # 自动格式化 Dart 代码文件 43 | dart format --fix r.dart 44 | -------------------------------------------------------------------------------- /test/widget_test.dart: -------------------------------------------------------------------------------- 1 | // This is a basic Flutter widget test. 2 | // 3 | // To perform an interaction with a widget in your test, use the WidgetTester 4 | // utility in the flutter_test package. For example, you can send tap and scroll 5 | // gestures. You can also use WidgetTester to find child widgets in the widget 6 | // tree, read text, and verify that the values of widget properties are correct. 7 | 8 | import 'package:flutter/material.dart'; 9 | import 'package:flutter_test/flutter_test.dart'; 10 | // import 'package:flutter_project/main.dart'; 11 | 12 | void main() { 13 | testWidgets('Counter increments smoke test', (WidgetTester tester) async { 14 | // Build our app and trigger a frame. 15 | // await tester.pumpWidget(const MyApp()); 16 | 17 | // Verify that our counter starts at 0. 18 | expect(find.text('0'), findsOneWidget); 19 | expect(find.text('1'), findsNothing); 20 | 21 | // Tap the '+' icon and trigger a frame. 22 | await tester.tap(find.byIcon(Icons.add)); 23 | await tester.pump(); 24 | 25 | // Verify that our counter has incremented. 26 | expect(find.text('0'), findsNothing); 27 | expect(find.text('1'), findsOneWidget); 28 | }); 29 | } 30 | -------------------------------------------------------------------------------- /web/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yixiaolunhui/flutter_project/788a64a93395b3fb32aad400b87785f252a8c71b/web/favicon.png -------------------------------------------------------------------------------- /web/icons/Icon-192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yixiaolunhui/flutter_project/788a64a93395b3fb32aad400b87785f252a8c71b/web/icons/Icon-192.png -------------------------------------------------------------------------------- /web/icons/Icon-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yixiaolunhui/flutter_project/788a64a93395b3fb32aad400b87785f252a8c71b/web/icons/Icon-512.png -------------------------------------------------------------------------------- /web/icons/Icon-maskable-192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yixiaolunhui/flutter_project/788a64a93395b3fb32aad400b87785f252a8c71b/web/icons/Icon-maskable-192.png -------------------------------------------------------------------------------- /web/icons/Icon-maskable-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yixiaolunhui/flutter_project/788a64a93395b3fb32aad400b87785f252a8c71b/web/icons/Icon-maskable-512.png -------------------------------------------------------------------------------- /web/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | flutter_project 33 | 34 | 35 | 39 | 40 | 41 | 42 | 43 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /web/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "flutter_project", 3 | "short_name": "flutter_project", 4 | "start_url": ".", 5 | "display": "standalone", 6 | "background_color": "#0175C2", 7 | "theme_color": "#0175C2", 8 | "description": "A new Flutter project.", 9 | "orientation": "portrait-primary", 10 | "prefer_related_applications": false, 11 | "icons": [ 12 | { 13 | "src": "icons/Icon-192.png", 14 | "sizes": "192x192", 15 | "type": "image/png" 16 | }, 17 | { 18 | "src": "icons/Icon-512.png", 19 | "sizes": "512x512", 20 | "type": "image/png" 21 | }, 22 | { 23 | "src": "icons/Icon-maskable-192.png", 24 | "sizes": "192x192", 25 | "type": "image/png", 26 | "purpose": "maskable" 27 | }, 28 | { 29 | "src": "icons/Icon-maskable-512.png", 30 | "sizes": "512x512", 31 | "type": "image/png", 32 | "purpose": "maskable" 33 | } 34 | ] 35 | } 36 | -------------------------------------------------------------------------------- /windows/.gitignore: -------------------------------------------------------------------------------- 1 | flutter/ephemeral/ 2 | 3 | # Visual Studio user-specific files. 4 | *.suo 5 | *.user 6 | *.userosscache 7 | *.sln.docstates 8 | 9 | # Visual Studio build-related files. 10 | x64/ 11 | x86/ 12 | 13 | # Visual Studio cache files 14 | # files ending in .cache can be ignored 15 | *.[Cc]ache 16 | # but keep track of directories ending in .cache 17 | !*.[Cc]ache/ 18 | -------------------------------------------------------------------------------- /windows/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Project-level configuration. 2 | cmake_minimum_required(VERSION 3.14) 3 | project(flutter_project LANGUAGES CXX) 4 | 5 | # The name of the executable created for the application. Change this to change 6 | # the on-disk name of your application. 7 | set(BINARY_NAME "flutter_project") 8 | 9 | # Explicitly opt in to modern CMake behaviors to avoid warnings with recent 10 | # versions of CMake. 11 | cmake_policy(SET CMP0063 NEW) 12 | 13 | # Define build configuration option. 14 | get_property(IS_MULTICONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) 15 | if(IS_MULTICONFIG) 16 | set(CMAKE_CONFIGURATION_TYPES "Debug;Profile;Release" 17 | CACHE STRING "" FORCE) 18 | else() 19 | if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) 20 | set(CMAKE_BUILD_TYPE "Debug" CACHE 21 | STRING "Flutter build mode" FORCE) 22 | set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS 23 | "Debug" "Profile" "Release") 24 | endif() 25 | endif() 26 | # Define settings for the Profile build mode. 27 | set(CMAKE_EXE_LINKER_FLAGS_PROFILE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}") 28 | set(CMAKE_SHARED_LINKER_FLAGS_PROFILE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}") 29 | set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE}") 30 | set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE}") 31 | 32 | # Use Unicode for all projects. 33 | add_definitions(-DUNICODE -D_UNICODE) 34 | 35 | # Compilation settings that should be applied to most targets. 36 | # 37 | # Be cautious about adding new options here, as plugins use this function by 38 | # default. In most cases, you should add new options to specific targets instead 39 | # of modifying this function. 40 | function(APPLY_STANDARD_SETTINGS TARGET) 41 | target_compile_features(${TARGET} PUBLIC cxx_std_17) 42 | target_compile_options(${TARGET} PRIVATE /W4 /WX /wd"4100") 43 | target_compile_options(${TARGET} PRIVATE /EHsc) 44 | target_compile_definitions(${TARGET} PRIVATE "_HAS_EXCEPTIONS=0") 45 | target_compile_definitions(${TARGET} PRIVATE "$<$:_DEBUG>") 46 | endfunction() 47 | 48 | # Flutter library and tool build rules. 49 | set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") 50 | add_subdirectory(${FLUTTER_MANAGED_DIR}) 51 | 52 | # Application build; see runner/CMakeLists.txt. 53 | add_subdirectory("runner") 54 | 55 | # Generated plugin build rules, which manage building the plugins and adding 56 | # them to the application. 57 | include(flutter/generated_plugins.cmake) 58 | 59 | 60 | # === Installation === 61 | # Support files are copied into place next to the executable, so that it can 62 | # run in place. This is done instead of making a separate bundle (as on Linux) 63 | # so that building and running from within Visual Studio will work. 64 | set(BUILD_BUNDLE_DIR "$") 65 | # Make the "install" step default, as it's required to run. 66 | set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1) 67 | if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) 68 | set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) 69 | endif() 70 | 71 | set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") 72 | set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}") 73 | 74 | install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" 75 | COMPONENT Runtime) 76 | 77 | install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" 78 | COMPONENT Runtime) 79 | 80 | install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 81 | COMPONENT Runtime) 82 | 83 | if(PLUGIN_BUNDLED_LIBRARIES) 84 | install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" 85 | DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 86 | COMPONENT Runtime) 87 | endif() 88 | 89 | # Fully re-copy the assets directory on each build to avoid having stale files 90 | # from a previous install. 91 | set(FLUTTER_ASSET_DIR_NAME "flutter_assets") 92 | install(CODE " 93 | file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") 94 | " COMPONENT Runtime) 95 | install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" 96 | DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) 97 | 98 | # Install the AOT library on non-Debug builds only. 99 | install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" 100 | CONFIGURATIONS Profile;Release 101 | COMPONENT Runtime) 102 | -------------------------------------------------------------------------------- /windows/flutter/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # This file controls Flutter-level build steps. It should not be edited. 2 | cmake_minimum_required(VERSION 3.14) 3 | 4 | set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") 5 | 6 | # Configuration provided via flutter tool. 7 | include(${EPHEMERAL_DIR}/generated_config.cmake) 8 | 9 | # TODO: Move the rest of this into files in ephemeral. See 10 | # https://github.com/flutter/flutter/issues/57146. 11 | set(WRAPPER_ROOT "${EPHEMERAL_DIR}/cpp_client_wrapper") 12 | 13 | # === Flutter Library === 14 | set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll") 15 | 16 | # Published to parent scope for install step. 17 | set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) 18 | set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) 19 | set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) 20 | set(AOT_LIBRARY "${PROJECT_DIR}/build/windows/app.so" PARENT_SCOPE) 21 | 22 | list(APPEND FLUTTER_LIBRARY_HEADERS 23 | "flutter_export.h" 24 | "flutter_windows.h" 25 | "flutter_messenger.h" 26 | "flutter_plugin_registrar.h" 27 | "flutter_texture_registrar.h" 28 | ) 29 | list(TRANSFORM FLUTTER_LIBRARY_HEADERS PREPEND "${EPHEMERAL_DIR}/") 30 | add_library(flutter INTERFACE) 31 | target_include_directories(flutter INTERFACE 32 | "${EPHEMERAL_DIR}" 33 | ) 34 | target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}.lib") 35 | add_dependencies(flutter flutter_assemble) 36 | 37 | # === Wrapper === 38 | list(APPEND CPP_WRAPPER_SOURCES_CORE 39 | "core_implementations.cc" 40 | "standard_codec.cc" 41 | ) 42 | list(TRANSFORM CPP_WRAPPER_SOURCES_CORE PREPEND "${WRAPPER_ROOT}/") 43 | list(APPEND CPP_WRAPPER_SOURCES_PLUGIN 44 | "plugin_registrar.cc" 45 | ) 46 | list(TRANSFORM CPP_WRAPPER_SOURCES_PLUGIN PREPEND "${WRAPPER_ROOT}/") 47 | list(APPEND CPP_WRAPPER_SOURCES_APP 48 | "flutter_engine.cc" 49 | "flutter_view_controller.cc" 50 | ) 51 | list(TRANSFORM CPP_WRAPPER_SOURCES_APP PREPEND "${WRAPPER_ROOT}/") 52 | 53 | # Wrapper sources needed for a plugin. 54 | add_library(flutter_wrapper_plugin STATIC 55 | ${CPP_WRAPPER_SOURCES_CORE} 56 | ${CPP_WRAPPER_SOURCES_PLUGIN} 57 | ) 58 | apply_standard_settings(flutter_wrapper_plugin) 59 | set_target_properties(flutter_wrapper_plugin PROPERTIES 60 | POSITION_INDEPENDENT_CODE ON) 61 | set_target_properties(flutter_wrapper_plugin PROPERTIES 62 | CXX_VISIBILITY_PRESET hidden) 63 | target_link_libraries(flutter_wrapper_plugin PUBLIC flutter) 64 | target_include_directories(flutter_wrapper_plugin PUBLIC 65 | "${WRAPPER_ROOT}/include" 66 | ) 67 | add_dependencies(flutter_wrapper_plugin flutter_assemble) 68 | 69 | # Wrapper sources needed for the runner. 70 | add_library(flutter_wrapper_app STATIC 71 | ${CPP_WRAPPER_SOURCES_CORE} 72 | ${CPP_WRAPPER_SOURCES_APP} 73 | ) 74 | apply_standard_settings(flutter_wrapper_app) 75 | target_link_libraries(flutter_wrapper_app PUBLIC flutter) 76 | target_include_directories(flutter_wrapper_app PUBLIC 77 | "${WRAPPER_ROOT}/include" 78 | ) 79 | add_dependencies(flutter_wrapper_app flutter_assemble) 80 | 81 | # === Flutter tool backend === 82 | # _phony_ is a non-existent file to force this command to run every time, 83 | # since currently there's no way to get a full input/output list from the 84 | # flutter tool. 85 | set(PHONY_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/_phony_") 86 | set_source_files_properties("${PHONY_OUTPUT}" PROPERTIES SYMBOLIC TRUE) 87 | add_custom_command( 88 | OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} 89 | ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} 90 | ${CPP_WRAPPER_SOURCES_APP} 91 | ${PHONY_OUTPUT} 92 | COMMAND ${CMAKE_COMMAND} -E env 93 | ${FLUTTER_TOOL_ENVIRONMENT} 94 | "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat" 95 | windows-x64 $ 96 | VERBATIM 97 | ) 98 | add_custom_target(flutter_assemble DEPENDS 99 | "${FLUTTER_LIBRARY}" 100 | ${FLUTTER_LIBRARY_HEADERS} 101 | ${CPP_WRAPPER_SOURCES_CORE} 102 | ${CPP_WRAPPER_SOURCES_PLUGIN} 103 | ${CPP_WRAPPER_SOURCES_APP} 104 | ) 105 | -------------------------------------------------------------------------------- /windows/flutter/generated_plugin_registrant.cc: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #include "generated_plugin_registrant.h" 8 | 9 | #include 10 | 11 | void RegisterPlugins(flutter::PluginRegistry* registry) { 12 | PermissionHandlerWindowsPluginRegisterWithRegistrar( 13 | registry->GetRegistrarForPlugin("PermissionHandlerWindowsPlugin")); 14 | } 15 | -------------------------------------------------------------------------------- /windows/flutter/generated_plugin_registrant.h: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #ifndef GENERATED_PLUGIN_REGISTRANT_ 8 | #define GENERATED_PLUGIN_REGISTRANT_ 9 | 10 | #include 11 | 12 | // Registers Flutter plugins. 13 | void RegisterPlugins(flutter::PluginRegistry* registry); 14 | 15 | #endif // GENERATED_PLUGIN_REGISTRANT_ 16 | -------------------------------------------------------------------------------- /windows/flutter/generated_plugins.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Generated file, do not edit. 3 | # 4 | 5 | list(APPEND FLUTTER_PLUGIN_LIST 6 | permission_handler_windows 7 | ) 8 | 9 | list(APPEND FLUTTER_FFI_PLUGIN_LIST 10 | ) 11 | 12 | set(PLUGIN_BUNDLED_LIBRARIES) 13 | 14 | foreach(plugin ${FLUTTER_PLUGIN_LIST}) 15 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/windows plugins/${plugin}) 16 | target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) 17 | list(APPEND PLUGIN_BUNDLED_LIBRARIES $) 18 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) 19 | endforeach(plugin) 20 | 21 | foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) 22 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin}) 23 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) 24 | endforeach(ffi_plugin) 25 | -------------------------------------------------------------------------------- /windows/runner/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.14) 2 | project(runner LANGUAGES CXX) 3 | 4 | # Define the application target. To change its name, change BINARY_NAME in the 5 | # top-level CMakeLists.txt, not the value here, or `flutter run` will no longer 6 | # work. 7 | # 8 | # Any new source files that you add to the application should be added here. 9 | add_executable(${BINARY_NAME} WIN32 10 | "flutter_window.cpp" 11 | "main.cpp" 12 | "utils.cpp" 13 | "win32_window.cpp" 14 | "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" 15 | "Runner.rc" 16 | "runner.exe.manifest" 17 | ) 18 | 19 | # Apply the standard set of build settings. This can be removed for applications 20 | # that need different build settings. 21 | apply_standard_settings(${BINARY_NAME}) 22 | 23 | # Add preprocessor definitions for the build version. 24 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION=\"${FLUTTER_VERSION}\"") 25 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MAJOR=${FLUTTER_VERSION_MAJOR}") 26 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MINOR=${FLUTTER_VERSION_MINOR}") 27 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_PATCH=${FLUTTER_VERSION_PATCH}") 28 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_BUILD=${FLUTTER_VERSION_BUILD}") 29 | 30 | # Disable Windows macros that collide with C++ standard library functions. 31 | target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX") 32 | 33 | # Add dependency libraries and include directories. Add any application-specific 34 | # dependencies here. 35 | target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app) 36 | target_link_libraries(${BINARY_NAME} PRIVATE "dwmapi.lib") 37 | target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") 38 | 39 | # Run the Flutter tool portions of the build. This must not be removed. 40 | add_dependencies(${BINARY_NAME} flutter_assemble) 41 | -------------------------------------------------------------------------------- /windows/runner/Runner.rc: -------------------------------------------------------------------------------- 1 | // Microsoft Visual C++ generated resource script. 2 | // 3 | #pragma code_page(65001) 4 | #include "resource.h" 5 | 6 | #define APSTUDIO_READONLY_SYMBOLS 7 | ///////////////////////////////////////////////////////////////////////////// 8 | // 9 | // Generated from the TEXTINCLUDE 2 resource. 10 | // 11 | #include "winres.h" 12 | 13 | ///////////////////////////////////////////////////////////////////////////// 14 | #undef APSTUDIO_READONLY_SYMBOLS 15 | 16 | ///////////////////////////////////////////////////////////////////////////// 17 | // English (United States) resources 18 | 19 | #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) 20 | LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US 21 | 22 | #ifdef APSTUDIO_INVOKED 23 | ///////////////////////////////////////////////////////////////////////////// 24 | // 25 | // TEXTINCLUDE 26 | // 27 | 28 | 1 TEXTINCLUDE 29 | BEGIN 30 | "resource.h\0" 31 | END 32 | 33 | 2 TEXTINCLUDE 34 | BEGIN 35 | "#include ""winres.h""\r\n" 36 | "\0" 37 | END 38 | 39 | 3 TEXTINCLUDE 40 | BEGIN 41 | "\r\n" 42 | "\0" 43 | END 44 | 45 | #endif // APSTUDIO_INVOKED 46 | 47 | 48 | ///////////////////////////////////////////////////////////////////////////// 49 | // 50 | // Icon 51 | // 52 | 53 | // Icon with lowest ID value placed first to ensure application icon 54 | // remains consistent on all systems. 55 | IDI_APP_ICON ICON "resources\\app_icon.ico" 56 | 57 | 58 | ///////////////////////////////////////////////////////////////////////////// 59 | // 60 | // Version 61 | // 62 | 63 | #if defined(FLUTTER_VERSION_MAJOR) && defined(FLUTTER_VERSION_MINOR) && defined(FLUTTER_VERSION_PATCH) && defined(FLUTTER_VERSION_BUILD) 64 | #define VERSION_AS_NUMBER FLUTTER_VERSION_MAJOR,FLUTTER_VERSION_MINOR,FLUTTER_VERSION_PATCH,FLUTTER_VERSION_BUILD 65 | #else 66 | #define VERSION_AS_NUMBER 1,0,0,0 67 | #endif 68 | 69 | #if defined(FLUTTER_VERSION) 70 | #define VERSION_AS_STRING FLUTTER_VERSION 71 | #else 72 | #define VERSION_AS_STRING "1.0.0" 73 | #endif 74 | 75 | VS_VERSION_INFO VERSIONINFO 76 | FILEVERSION VERSION_AS_NUMBER 77 | PRODUCTVERSION VERSION_AS_NUMBER 78 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK 79 | #ifdef _DEBUG 80 | FILEFLAGS VS_FF_DEBUG 81 | #else 82 | FILEFLAGS 0x0L 83 | #endif 84 | FILEOS VOS__WINDOWS32 85 | FILETYPE VFT_APP 86 | FILESUBTYPE 0x0L 87 | BEGIN 88 | BLOCK "StringFileInfo" 89 | BEGIN 90 | BLOCK "040904e4" 91 | BEGIN 92 | VALUE "CompanyName", "com.project" "\0" 93 | VALUE "FileDescription", "flutter_project" "\0" 94 | VALUE "FileVersion", VERSION_AS_STRING "\0" 95 | VALUE "InternalName", "flutter_project" "\0" 96 | VALUE "LegalCopyright", "Copyright (C) 2024 com.project. All rights reserved." "\0" 97 | VALUE "OriginalFilename", "flutter_project.exe" "\0" 98 | VALUE "ProductName", "flutter_project" "\0" 99 | VALUE "ProductVersion", VERSION_AS_STRING "\0" 100 | END 101 | END 102 | BLOCK "VarFileInfo" 103 | BEGIN 104 | VALUE "Translation", 0x409, 1252 105 | END 106 | END 107 | 108 | #endif // English (United States) resources 109 | ///////////////////////////////////////////////////////////////////////////// 110 | 111 | 112 | 113 | #ifndef APSTUDIO_INVOKED 114 | ///////////////////////////////////////////////////////////////////////////// 115 | // 116 | // Generated from the TEXTINCLUDE 3 resource. 117 | // 118 | 119 | 120 | ///////////////////////////////////////////////////////////////////////////// 121 | #endif // not APSTUDIO_INVOKED 122 | -------------------------------------------------------------------------------- /windows/runner/flutter_window.cpp: -------------------------------------------------------------------------------- 1 | #include "flutter_window.h" 2 | 3 | #include 4 | 5 | #include "flutter/generated_plugin_registrant.h" 6 | 7 | FlutterWindow::FlutterWindow(const flutter::DartProject& project) 8 | : project_(project) {} 9 | 10 | FlutterWindow::~FlutterWindow() {} 11 | 12 | bool FlutterWindow::OnCreate() { 13 | if (!Win32Window::OnCreate()) { 14 | return false; 15 | } 16 | 17 | RECT frame = GetClientArea(); 18 | 19 | // The size here must match the window dimensions to avoid unnecessary surface 20 | // creation / destruction in the startup path. 21 | flutter_controller_ = std::make_unique( 22 | frame.right - frame.left, frame.bottom - frame.top, project_); 23 | // Ensure that basic setup of the controller was successful. 24 | if (!flutter_controller_->engine() || !flutter_controller_->view()) { 25 | return false; 26 | } 27 | RegisterPlugins(flutter_controller_->engine()); 28 | SetChildContent(flutter_controller_->view()->GetNativeWindow()); 29 | 30 | flutter_controller_->engine()->SetNextFrameCallback([&]() { 31 | this->Show(); 32 | }); 33 | 34 | return true; 35 | } 36 | 37 | void FlutterWindow::OnDestroy() { 38 | if (flutter_controller_) { 39 | flutter_controller_ = nullptr; 40 | } 41 | 42 | Win32Window::OnDestroy(); 43 | } 44 | 45 | LRESULT 46 | FlutterWindow::MessageHandler(HWND hwnd, UINT const message, 47 | WPARAM const wparam, 48 | LPARAM const lparam) noexcept { 49 | // Give Flutter, including plugins, an opportunity to handle window messages. 50 | if (flutter_controller_) { 51 | std::optional result = 52 | flutter_controller_->HandleTopLevelWindowProc(hwnd, message, wparam, 53 | lparam); 54 | if (result) { 55 | return *result; 56 | } 57 | } 58 | 59 | switch (message) { 60 | case WM_FONTCHANGE: 61 | flutter_controller_->engine()->ReloadSystemFonts(); 62 | break; 63 | } 64 | 65 | return Win32Window::MessageHandler(hwnd, message, wparam, lparam); 66 | } 67 | -------------------------------------------------------------------------------- /windows/runner/flutter_window.h: -------------------------------------------------------------------------------- 1 | #ifndef RUNNER_FLUTTER_WINDOW_H_ 2 | #define RUNNER_FLUTTER_WINDOW_H_ 3 | 4 | #include 5 | #include 6 | 7 | #include 8 | 9 | #include "win32_window.h" 10 | 11 | // A window that does nothing but host a Flutter view. 12 | class FlutterWindow : public Win32Window { 13 | public: 14 | // Creates a new FlutterWindow hosting a Flutter view running |project|. 15 | explicit FlutterWindow(const flutter::DartProject& project); 16 | virtual ~FlutterWindow(); 17 | 18 | protected: 19 | // Win32Window: 20 | bool OnCreate() override; 21 | void OnDestroy() override; 22 | LRESULT MessageHandler(HWND window, UINT const message, WPARAM const wparam, 23 | LPARAM const lparam) noexcept override; 24 | 25 | private: 26 | // The project to run. 27 | flutter::DartProject project_; 28 | 29 | // The Flutter instance hosted by this window. 30 | std::unique_ptr flutter_controller_; 31 | }; 32 | 33 | #endif // RUNNER_FLUTTER_WINDOW_H_ 34 | -------------------------------------------------------------------------------- /windows/runner/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "flutter_window.h" 6 | #include "utils.h" 7 | 8 | int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev, 9 | _In_ wchar_t *command_line, _In_ int show_command) { 10 | // Attach to console when present (e.g., 'flutter run') or create a 11 | // new console when running with a debugger. 12 | if (!::AttachConsole(ATTACH_PARENT_PROCESS) && ::IsDebuggerPresent()) { 13 | CreateAndAttachConsole(); 14 | } 15 | 16 | // Initialize COM, so that it is available for use in the library and/or 17 | // plugins. 18 | ::CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED); 19 | 20 | flutter::DartProject project(L"data"); 21 | 22 | std::vector command_line_arguments = 23 | GetCommandLineArguments(); 24 | 25 | project.set_dart_entrypoint_arguments(std::move(command_line_arguments)); 26 | 27 | FlutterWindow window(project); 28 | Win32Window::Point origin(10, 10); 29 | Win32Window::Size size(1280, 720); 30 | if (!window.Create(L"flutter_project", origin, size)) { 31 | return EXIT_FAILURE; 32 | } 33 | window.SetQuitOnClose(true); 34 | 35 | ::MSG msg; 36 | while (::GetMessage(&msg, nullptr, 0, 0)) { 37 | ::TranslateMessage(&msg); 38 | ::DispatchMessage(&msg); 39 | } 40 | 41 | ::CoUninitialize(); 42 | return EXIT_SUCCESS; 43 | } 44 | -------------------------------------------------------------------------------- /windows/runner/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by Runner.rc 4 | // 5 | #define IDI_APP_ICON 101 6 | 7 | // Next default values for new objects 8 | // 9 | #ifdef APSTUDIO_INVOKED 10 | #ifndef APSTUDIO_READONLY_SYMBOLS 11 | #define _APS_NEXT_RESOURCE_VALUE 102 12 | #define _APS_NEXT_COMMAND_VALUE 40001 13 | #define _APS_NEXT_CONTROL_VALUE 1001 14 | #define _APS_NEXT_SYMED_VALUE 101 15 | #endif 16 | #endif 17 | -------------------------------------------------------------------------------- /windows/runner/resources/app_icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yixiaolunhui/flutter_project/788a64a93395b3fb32aad400b87785f252a8c71b/windows/runner/resources/app_icon.ico -------------------------------------------------------------------------------- /windows/runner/runner.exe.manifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PerMonitorV2 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /windows/runner/utils.cpp: -------------------------------------------------------------------------------- 1 | #include "utils.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include 9 | 10 | void CreateAndAttachConsole() { 11 | if (::AllocConsole()) { 12 | FILE *unused; 13 | if (freopen_s(&unused, "CONOUT$", "w", stdout)) { 14 | _dup2(_fileno(stdout), 1); 15 | } 16 | if (freopen_s(&unused, "CONOUT$", "w", stderr)) { 17 | _dup2(_fileno(stdout), 2); 18 | } 19 | std::ios::sync_with_stdio(); 20 | FlutterDesktopResyncOutputStreams(); 21 | } 22 | } 23 | 24 | std::vector GetCommandLineArguments() { 25 | // Convert the UTF-16 command line arguments to UTF-8 for the Engine to use. 26 | int argc; 27 | wchar_t** argv = ::CommandLineToArgvW(::GetCommandLineW(), &argc); 28 | if (argv == nullptr) { 29 | return std::vector(); 30 | } 31 | 32 | std::vector command_line_arguments; 33 | 34 | // Skip the first argument as it's the binary name. 35 | for (int i = 1; i < argc; i++) { 36 | command_line_arguments.push_back(Utf8FromUtf16(argv[i])); 37 | } 38 | 39 | ::LocalFree(argv); 40 | 41 | return command_line_arguments; 42 | } 43 | 44 | std::string Utf8FromUtf16(const wchar_t* utf16_string) { 45 | if (utf16_string == nullptr) { 46 | return std::string(); 47 | } 48 | int target_length = ::WideCharToMultiByte( 49 | CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, 50 | -1, nullptr, 0, nullptr, nullptr); 51 | std::string utf8_string; 52 | if (target_length == 0 || target_length > utf8_string.max_size()) { 53 | return utf8_string; 54 | } 55 | utf8_string.resize(target_length); 56 | int converted_length = ::WideCharToMultiByte( 57 | CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, 58 | -1, utf8_string.data(), 59 | target_length, nullptr, nullptr); 60 | if (converted_length == 0) { 61 | return std::string(); 62 | } 63 | return utf8_string; 64 | } 65 | -------------------------------------------------------------------------------- /windows/runner/utils.h: -------------------------------------------------------------------------------- 1 | #ifndef RUNNER_UTILS_H_ 2 | #define RUNNER_UTILS_H_ 3 | 4 | #include 5 | #include 6 | 7 | // Creates a console for the process, and redirects stdout and stderr to 8 | // it for both the runner and the Flutter library. 9 | void CreateAndAttachConsole(); 10 | 11 | // Takes a null-terminated wchar_t* encoded in UTF-16 and returns a std::string 12 | // encoded in UTF-8. Returns an empty std::string on failure. 13 | std::string Utf8FromUtf16(const wchar_t* utf16_string); 14 | 15 | // Gets the command line arguments passed in as a std::vector, 16 | // encoded in UTF-8. Returns an empty std::vector on failure. 17 | std::vector GetCommandLineArguments(); 18 | 19 | #endif // RUNNER_UTILS_H_ 20 | -------------------------------------------------------------------------------- /windows/runner/win32_window.h: -------------------------------------------------------------------------------- 1 | #ifndef RUNNER_WIN32_WINDOW_H_ 2 | #define RUNNER_WIN32_WINDOW_H_ 3 | 4 | #include 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | // A class abstraction for a high DPI-aware Win32 Window. Intended to be 11 | // inherited from by classes that wish to specialize with custom 12 | // rendering and input handling 13 | class Win32Window { 14 | public: 15 | struct Point { 16 | unsigned int x; 17 | unsigned int y; 18 | Point(unsigned int x, unsigned int y) : x(x), y(y) {} 19 | }; 20 | 21 | struct Size { 22 | unsigned int width; 23 | unsigned int height; 24 | Size(unsigned int width, unsigned int height) 25 | : width(width), height(height) {} 26 | }; 27 | 28 | Win32Window(); 29 | virtual ~Win32Window(); 30 | 31 | // Creates a win32 window with |title| that is positioned and sized using 32 | // |origin| and |size|. New windows are created on the default monitor. Window 33 | // sizes are specified to the OS in physical pixels, hence to ensure a 34 | // consistent size this function will scale the inputted width and height as 35 | // as appropriate for the default monitor. The window is invisible until 36 | // |Show| is called. Returns true if the window was created successfully. 37 | bool Create(const std::wstring& title, const Point& origin, const Size& size); 38 | 39 | // Show the current window. Returns true if the window was successfully shown. 40 | bool Show(); 41 | 42 | // Release OS resources associated with window. 43 | void Destroy(); 44 | 45 | // Inserts |content| into the window tree. 46 | void SetChildContent(HWND content); 47 | 48 | // Returns the backing Window handle to enable clients to set icon and other 49 | // window properties. Returns nullptr if the window has been destroyed. 50 | HWND GetHandle(); 51 | 52 | // If true, closing this window will quit the application. 53 | void SetQuitOnClose(bool quit_on_close); 54 | 55 | // Return a RECT representing the bounds of the current client area. 56 | RECT GetClientArea(); 57 | 58 | protected: 59 | // Processes and route salient window messages for mouse handling, 60 | // size change and DPI. Delegates handling of these to member overloads that 61 | // inheriting classes can handle. 62 | virtual LRESULT MessageHandler(HWND window, 63 | UINT const message, 64 | WPARAM const wparam, 65 | LPARAM const lparam) noexcept; 66 | 67 | // Called when CreateAndShow is called, allowing subclass window-related 68 | // setup. Subclasses should return false if setup fails. 69 | virtual bool OnCreate(); 70 | 71 | // Called when Destroy is called. 72 | virtual void OnDestroy(); 73 | 74 | private: 75 | friend class WindowClassRegistrar; 76 | 77 | // OS callback called by message pump. Handles the WM_NCCREATE message which 78 | // is passed when the non-client area is being created and enables automatic 79 | // non-client DPI scaling so that the non-client area automatically 80 | // responsponds to changes in DPI. All other messages are handled by 81 | // MessageHandler. 82 | static LRESULT CALLBACK WndProc(HWND const window, 83 | UINT const message, 84 | WPARAM const wparam, 85 | LPARAM const lparam) noexcept; 86 | 87 | // Retrieves a class instance pointer for |window| 88 | static Win32Window* GetThisFromHandle(HWND const window) noexcept; 89 | 90 | // Update the window frame's theme to match the system theme. 91 | static void UpdateTheme(HWND const window); 92 | 93 | bool quit_on_close_ = false; 94 | 95 | // window handle for top level window. 96 | HWND window_handle_ = nullptr; 97 | 98 | // window handle for hosted content. 99 | HWND child_content_ = nullptr; 100 | }; 101 | 102 | #endif // RUNNER_WIN32_WINDOW_H_ 103 | --------------------------------------------------------------------------------