├── .gitignore ├── .metadata ├── README.md ├── analysis_options.yaml ├── android ├── .gitignore ├── app │ ├── build.gradle │ └── src │ │ ├── debug │ │ └── AndroidManifest.xml │ │ ├── main │ │ ├── AndroidManifest.xml │ │ ├── java │ │ │ └── com │ │ │ │ └── studyyoun │ │ │ │ └── flutter_ho │ │ │ │ └── MainActivity.java │ │ └── res │ │ │ ├── drawable-v21 │ │ │ └── launch_background.xml │ │ │ ├── drawable │ │ │ └── launch_background.xml │ │ │ ├── mipmap-hdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-mdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xhdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxhdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxxhdpi │ │ │ └── ic_launcher.png │ │ │ ├── values-night │ │ │ └── styles.xml │ │ │ └── values │ │ │ └── styles.xml │ │ └── profile │ │ └── AndroidManifest.xml ├── build.gradle ├── gradle.properties └── settings.gradle ├── assets ├── images │ ├── app_icon.png │ ├── banner1.png │ ├── banner2.png │ ├── banner3.png │ ├── login_bg.webp │ ├── login_bg_2.webp │ ├── p1.webp │ ├── p2.webp │ ├── p3.webp │ ├── sp01.png │ ├── sp02.png │ ├── sp03.png │ ├── sp05.png │ ├── test_icon.png │ └── welcome.png ├── svg │ ├── door_lock.svg │ └── door_unlock.svg └── video │ ├── list_item.mp4 │ └── welcom.mp4 ├── demoImages └── flutter_image_scan.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.h │ ├── AppDelegate.m │ ├── 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 │ └── main.m ├── lib ├── main.dart └── src │ ├── bean │ ├── bean_art.dart │ ├── bean_demo.dart │ ├── bean_user.dart │ └── bean_version.dart │ ├── first_guild_page.dart │ ├── home_page.dart │ ├── index_page.dart │ ├── net │ ├── dio_utils.dart │ ├── http_helper.dart │ └── log_interceptor.dart │ ├── pages │ ├── common │ │ ├── app_upgrade.dart │ │ ├── common_webview.dart │ │ ├── controller.dart │ │ ├── perlmisson_request_widget.dart │ │ ├── protocol_model.dart │ │ └── user_helper.dart │ ├── demo │ │ ├── banner_widget.dart │ │ ├── demo1 │ │ │ ├── demo_image_scan_main_page.dart │ │ │ ├── image_scan_widget.dart │ │ │ └── targ_image_page.dart │ │ ├── demo10 │ │ │ └── segment_demo.dart │ │ ├── demo11 │ │ │ ├── tooltips_demo.dart │ │ │ └── tooltips_demo2.dart │ │ ├── demo12 │ │ │ └── PieChartWidget.dart │ │ ├── demo13 │ │ │ └── test_widget.dart │ │ ├── demo14 │ │ │ ├── demo_ListViewFag.dart │ │ │ ├── demo_ListViewFag2.dart │ │ │ ├── demo_ListViewFag3.dart │ │ │ └── demo_ListViewMonth.dart │ │ ├── demo15 │ │ │ └── demo_BottomNavigationBar.dart │ │ ├── demo16 │ │ │ └── demo_ConnectivityPage.dart │ │ ├── demo17 │ │ │ └── demo_DateRangPage.dart │ │ ├── demo18 │ │ │ └── demo_DateRangPage.dart │ │ ├── demo19 │ │ │ └── demo_WillPopScope.dart │ │ ├── demo2 │ │ │ ├── list_demo2_item_widget.dart │ │ │ └── list_main_demo.dart │ │ ├── demo20 │ │ │ ├── demo_AnimatedBuilder.dart │ │ │ └── demo_AnimationWidget.dart │ │ ├── demo21 │ │ │ └── demo_StreamBuilder.dart │ │ ├── demo22 │ │ │ └── demo_LoadingWidget.dart │ │ ├── demo23 │ │ │ ├── demo_BackdropFiltert.dart │ │ │ └── demo_ProgressBar.dart │ │ ├── demo24 │ │ │ ├── SelectPhotoWidget.dart │ │ │ └── demo_SelectImageWidget.dart │ │ ├── demo25 │ │ │ └── demo_MouseRegion.dart │ │ ├── demo26 │ │ │ └── demo_Signature.dart │ │ ├── demo27 │ │ │ ├── a_widget.dart │ │ │ ├── ab.dart │ │ │ ├── b_widget.dart │ │ │ └── demo_Stream.dart │ │ ├── demo28 │ │ │ └── demo_AnimationText.dart │ │ ├── demo29 │ │ │ └── demo_InputTipsWidget.dart │ │ ├── demo3 │ │ │ ├── GridViewBean.dart │ │ │ ├── GridViewDemo.dart │ │ │ └── GridViewItemWidget.dart │ │ ├── demo30 │ │ │ └── demo_demo_Scaffold_01.dart │ │ ├── demo31 │ │ │ ├── Snake.dart │ │ │ └── demo_sensors_plus.dart │ │ ├── demo32 │ │ │ ├── TimerPicker.dart │ │ │ ├── date_select_day_widget.dart │ │ │ ├── date_select_item_widget.dart │ │ │ └── demo_demo_Scaffold_01.dart │ │ ├── demo33 │ │ │ ├── demo_Align.dart │ │ │ ├── demo_AlignTransition.dart │ │ │ ├── demo_AnimatedContainer.dart │ │ │ ├── demo_AnimatedDefaultTextStyle.dart │ │ │ ├── demo_AnimatedList.dart │ │ │ ├── demo_AnimatedOpacity.dart │ │ │ ├── demo_AnimatedPaddind.dart │ │ │ ├── demo_AnimatedPhysicalModel.dart │ │ │ ├── demo_AnimatedPositionedDirectional.dart │ │ │ ├── demo_AnimatedSwitcher.dart │ │ │ ├── demo_Positioned.dart │ │ │ ├── demo_PositionedTransition.dart │ │ │ ├── demo_RelativePositionedTransition.dart │ │ │ ├── demo_RotationTransition.dart │ │ │ ├── demo_ScaleTransition.dart │ │ │ ├── demo_SizeTransition.dart │ │ │ ├── demo_SlideTransition.dart │ │ │ ├── demo_SliverAnimatedOpacity.dart │ │ │ ├── demo_TextLiquidFill.dart │ │ │ └── hero │ │ │ │ └── demo_HeroDemoPage.dart │ │ ├── demo34 │ │ │ └── demo_TextField.dart │ │ ├── demo35 │ │ │ ├── demo_TransformImagePage.dart │ │ │ ├── demo_TransformMatrix4Page.dart │ │ │ ├── demo_TransformPage.dart │ │ │ ├── demo_TransformPage2.dart │ │ │ └── demo_TransformPageView.dart │ │ ├── demo36 │ │ │ ├── demo_ColorTweenPage.dart │ │ │ └── demo_IntervalPage.dart │ │ ├── demo37 │ │ │ └── AnimationWidget.dart │ │ ├── demo38 │ │ │ ├── demo_demo_AnimatedSwitcher.dart │ │ │ ├── demo_demo_TweenAnimatedBuilder.dart │ │ │ ├── image_show_page.dart │ │ │ ├── layout_page.dart │ │ │ ├── ui_loading_animation.dart │ │ │ └── widget_masker.dart │ │ ├── demo39 │ │ │ ├── demo_Container.dart │ │ │ ├── demo_Container2.dart │ │ │ └── demo_Container3.dart │ │ ├── demo4 │ │ │ ├── FlowFliterWidget.dart │ │ │ ├── FlowItemWidget.dart │ │ │ └── LoginHouCheDemo.dart │ │ ├── demo40 │ │ │ ├── demo_Code_Verification.dart │ │ │ └── demo_Form.dart │ │ ├── demo5 │ │ │ └── slider_demo_page.dart │ │ ├── demo6 │ │ │ └── image_scan_demo_page.dart │ │ ├── demo7 │ │ │ └── custom_tab_widget.dart │ │ ├── demo8 │ │ │ ├── animation_1_expand_card.dart │ │ │ ├── animation_2_pageview_image.dart │ │ │ └── animation_3_grid_image.dart │ │ ├── demo9 │ │ │ └── animation_4_list_image.dart │ │ ├── demo_login.dart │ │ ├── demo_pie.dart │ │ ├── demo_progress.dart │ │ ├── demo_scroll_index_list.dart │ │ ├── demo_sign_swip.dart │ │ ├── demo_video_list.dart │ │ ├── demo_work_recoder_page.dart │ │ ├── home_item_demo_page.dart │ │ ├── home_item_tabbar_page.dart │ │ ├── model │ │ │ └── demo_model.dart │ │ └── widget │ │ │ ├── demo_PageFlipBuilder.dart │ │ │ ├── demo_PhysicalModel.dart │ │ │ ├── demo_PhysicalModel2.dart │ │ │ ├── demo_RotatedBox.dart │ │ │ └── demo_Slidable.dart │ ├── home │ │ ├── home_art_list_item_widget.dart │ │ ├── home_item3_page.dart │ │ ├── home_item_page.dart │ │ ├── list_item2_widget.dart │ │ └── list_item_widget.dart │ ├── login │ │ ├── bg │ │ │ ├── bubble_bean.dart │ │ │ ├── bubble_painter.dart │ │ │ ├── bubble_widget.dart │ │ │ └── snow_date_page.dart │ │ ├── custom_textfield_widget.dart │ │ └── login_page.dart │ ├── mine │ │ ├── mine_login_page.dart │ │ ├── mine_main_page.dart │ │ ├── mine_no_login_page.dart │ │ └── setting_page.dart │ └── play │ │ ├── video_details2_widget.dart │ │ └── video_details_widget.dart │ ├── root_app_page.dart │ ├── test │ ├── test_colors_page.dart │ └── test_demo.dart │ ├── utils │ ├── aes_utils.dart │ ├── color_utils.dart │ ├── date_utils.dart │ ├── gzip_utils.dart │ ├── log_utils.dart │ ├── navigator_utils.dart │ ├── number_utils.dart │ ├── sp_utils.dart │ └── toast_utils.dart │ ├── welcom_time_widget.dart │ ├── welcom_video_widget.dart │ └── welcome_page.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 ├── 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 /.gitignore: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | *.class 3 | *.log 4 | *.pyc 5 | *.swp 6 | .DS_Store 7 | .atom/ 8 | .buildlog/ 9 | .history 10 | .svn/ 11 | 12 | # IntelliJ related 13 | *.iml 14 | *.ipr 15 | *.iws 16 | .idea/ 17 | 18 | # The .vscode folder contains launch configuration and tasks you configure in 19 | # VS Code which you may wish to be included in version control, so this line 20 | # is commented out by default. 21 | #.vscode/ 22 | 23 | # Flutter/Dart/Pub related 24 | **/doc/api/ 25 | **/ios/Flutter/.last_build_id 26 | .dart_tool/ 27 | .flutter-plugins 28 | .flutter-plugins-dependencies 29 | .packages 30 | .pub-cache/ 31 | .pub/ 32 | /build/ 33 | 34 | # Web related 35 | lib/generated_plugin_registrant.dart 36 | 37 | # Symbolication related 38 | app.*.symbols 39 | 40 | # Obfuscation related 41 | app.*.map.json 42 | 43 | # Android Studio will place build artifacts here 44 | /android/app/debug 45 | /android/app/profile 46 | /android/app/release 47 | -------------------------------------------------------------------------------- /.metadata: -------------------------------------------------------------------------------- 1 | # This file tracks properties of this Flutter project. 2 | # Used by Flutter tool to assess capabilities and perform upgrades etc. 3 | # 4 | # This file should be version controlled and should not be manually edited. 5 | 6 | version: 7 | revision: 097d3313d8e2c7f901932d63e537c1acefb87800 8 | channel: stable 9 | 10 | project_type: app 11 | -------------------------------------------------------------------------------- /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 -> 5 | localProperties.load(reader) 6 | } 7 | } 8 | 9 | def flutterRoot = localProperties.getProperty('flutter.sdk') 10 | if (flutterRoot == null) { 11 | throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") 12 | } 13 | 14 | def flutterVersionCode = localProperties.getProperty('flutter.versionCode') 15 | if (flutterVersionCode == null) { 16 | flutterVersionCode = '1' 17 | } 18 | 19 | def flutterVersionName = localProperties.getProperty('flutter.versionName') 20 | if (flutterVersionName == null) { 21 | flutterVersionName = '1.0' 22 | } 23 | 24 | apply plugin: 'com.android.application' 25 | apply plugin: 'kotlin-android' 26 | apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" 27 | 28 | android { 29 | compileSdkVersion flutter.compileSdkVersion 30 | 31 | compileOptions { 32 | sourceCompatibility JavaVersion.VERSION_1_8 33 | targetCompatibility JavaVersion.VERSION_1_8 34 | } 35 | 36 | defaultConfig { 37 | // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). 38 | applicationId "com.studyyoun.flutter_ho" 39 | minSdkVersion 19 40 | targetSdkVersion flutter.targetSdkVersion 41 | versionCode flutterVersionCode.toInteger() 42 | versionName flutterVersionName 43 | } 44 | 45 | buildTypes { 46 | release { 47 | // TODO: Add your own signing config for the release build. 48 | // Signing with the debug keys for now, so `flutter run --release` works. 49 | signingConfig signingConfigs.debug 50 | } 51 | } 52 | } 53 | 54 | flutter { 55 | source '../..' 56 | } 57 | -------------------------------------------------------------------------------- /android/app/src/debug/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 8 | 16 | 20 | 24 | 25 | 26 | 27 | 28 | 29 | 31 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /android/app/src/main/java/com/studyyoun/flutter_ho/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.studyyoun.flutter_ho; 2 | 3 | import io.flutter.embedding.android.FlutterActivity; 4 | 5 | public class MainActivity extends FlutterActivity { 6 | } 7 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable-v21/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhaolongs/flutter-ho/d7e4bd24d5325aa896ea96725fc851044b003b00/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhaolongs/flutter-ho/d7e4bd24d5325aa896ea96725fc851044b003b00/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhaolongs/flutter-ho/d7e4bd24d5325aa896ea96725fc851044b003b00/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhaolongs/flutter-ho/d7e4bd24d5325aa896ea96725fc851044b003b00/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhaolongs/flutter-ho/d7e4bd24d5325aa896ea96725fc851044b003b00/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/values-night/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 15 | 18 | 19 | -------------------------------------------------------------------------------- /android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 15 | 18 | 19 | -------------------------------------------------------------------------------- /android/app/src/profile/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /android/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | ext.kotlin_version = '1.6.10' 3 | repositories { 4 | google() 5 | mavenCentral() 6 | } 7 | 8 | dependencies { 9 | classpath 'com.android.tools.build:gradle:4.1.0' 10 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 11 | } 12 | } 13 | 14 | allprojects { 15 | repositories { 16 | google() 17 | mavenCentral() 18 | } 19 | } 20 | 21 | rootProject.buildDir = '../build' 22 | subprojects { 23 | project.buildDir = "${rootProject.buildDir}/${project.name}" 24 | } 25 | subprojects { 26 | project.evaluationDependsOn(':app') 27 | } 28 | 29 | task clean(type: Delete) { 30 | delete rootProject.buildDir 31 | } 32 | -------------------------------------------------------------------------------- /android/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx1536M 2 | android.useAndroidX=true 3 | android.enableJetifier=true 4 | -------------------------------------------------------------------------------- /android/settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | 3 | def localPropertiesFile = new File(rootProject.projectDir, "local.properties") 4 | def properties = new Properties() 5 | 6 | assert localPropertiesFile.exists() 7 | localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) } 8 | 9 | def flutterSdkPath = properties.getProperty("flutter.sdk") 10 | assert flutterSdkPath != null, "flutter.sdk not set in local.properties" 11 | apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle" 12 | -------------------------------------------------------------------------------- /assets/images/app_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhaolongs/flutter-ho/d7e4bd24d5325aa896ea96725fc851044b003b00/assets/images/app_icon.png -------------------------------------------------------------------------------- /assets/images/banner1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhaolongs/flutter-ho/d7e4bd24d5325aa896ea96725fc851044b003b00/assets/images/banner1.png -------------------------------------------------------------------------------- /assets/images/banner2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhaolongs/flutter-ho/d7e4bd24d5325aa896ea96725fc851044b003b00/assets/images/banner2.png -------------------------------------------------------------------------------- /assets/images/banner3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhaolongs/flutter-ho/d7e4bd24d5325aa896ea96725fc851044b003b00/assets/images/banner3.png -------------------------------------------------------------------------------- /assets/images/login_bg.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhaolongs/flutter-ho/d7e4bd24d5325aa896ea96725fc851044b003b00/assets/images/login_bg.webp -------------------------------------------------------------------------------- /assets/images/login_bg_2.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhaolongs/flutter-ho/d7e4bd24d5325aa896ea96725fc851044b003b00/assets/images/login_bg_2.webp -------------------------------------------------------------------------------- /assets/images/p1.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhaolongs/flutter-ho/d7e4bd24d5325aa896ea96725fc851044b003b00/assets/images/p1.webp -------------------------------------------------------------------------------- /assets/images/p2.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhaolongs/flutter-ho/d7e4bd24d5325aa896ea96725fc851044b003b00/assets/images/p2.webp -------------------------------------------------------------------------------- /assets/images/p3.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhaolongs/flutter-ho/d7e4bd24d5325aa896ea96725fc851044b003b00/assets/images/p3.webp -------------------------------------------------------------------------------- /assets/images/sp01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhaolongs/flutter-ho/d7e4bd24d5325aa896ea96725fc851044b003b00/assets/images/sp01.png -------------------------------------------------------------------------------- /assets/images/sp02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhaolongs/flutter-ho/d7e4bd24d5325aa896ea96725fc851044b003b00/assets/images/sp02.png -------------------------------------------------------------------------------- /assets/images/sp03.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhaolongs/flutter-ho/d7e4bd24d5325aa896ea96725fc851044b003b00/assets/images/sp03.png -------------------------------------------------------------------------------- /assets/images/sp05.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhaolongs/flutter-ho/d7e4bd24d5325aa896ea96725fc851044b003b00/assets/images/sp05.png -------------------------------------------------------------------------------- /assets/images/test_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhaolongs/flutter-ho/d7e4bd24d5325aa896ea96725fc851044b003b00/assets/images/test_icon.png -------------------------------------------------------------------------------- /assets/images/welcome.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhaolongs/flutter-ho/d7e4bd24d5325aa896ea96725fc851044b003b00/assets/images/welcome.png -------------------------------------------------------------------------------- /assets/svg/door_lock.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | Left door lock 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /assets/svg/door_unlock.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | Left door unlock 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /assets/video/list_item.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhaolongs/flutter-ho/d7e4bd24d5325aa896ea96725fc851044b003b00/assets/video/list_item.mp4 -------------------------------------------------------------------------------- /assets/video/welcom.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhaolongs/flutter-ho/d7e4bd24d5325aa896ea96725fc851044b003b00/assets/video/welcom.mp4 -------------------------------------------------------------------------------- /demoImages/flutter_image_scan.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhaolongs/flutter-ho/d7e4bd24d5325aa896ea96725fc851044b003b00/demoImages/flutter_image_scan.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 | 9.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, '9.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 | flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__)) 32 | end 33 | 34 | post_install do |installer| 35 | installer.pods_project.targets.each do |target| 36 | flutter_additional_ios_build_settings(target) 37 | end 38 | end 39 | -------------------------------------------------------------------------------- /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.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /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.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | @interface AppDelegate : FlutterAppDelegate 5 | 6 | @end 7 | -------------------------------------------------------------------------------- /ios/Runner/AppDelegate.m: -------------------------------------------------------------------------------- 1 | #import "AppDelegate.h" 2 | #import "GeneratedPluginRegistrant.h" 3 | 4 | @implementation AppDelegate 5 | 6 | - (BOOL)application:(UIApplication *)application 7 | didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 8 | [GeneratedPluginRegistrant registerWithRegistry:self]; 9 | // Override point for customization after application launch. 10 | return [super application:application didFinishLaunchingWithOptions:launchOptions]; 11 | } 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhaolongs/flutter-ho/d7e4bd24d5325aa896ea96725fc851044b003b00/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/zhaolongs/flutter-ho/d7e4bd24d5325aa896ea96725fc851044b003b00/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/zhaolongs/flutter-ho/d7e4bd24d5325aa896ea96725fc851044b003b00/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/zhaolongs/flutter-ho/d7e4bd24d5325aa896ea96725fc851044b003b00/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/zhaolongs/flutter-ho/d7e4bd24d5325aa896ea96725fc851044b003b00/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/zhaolongs/flutter-ho/d7e4bd24d5325aa896ea96725fc851044b003b00/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/zhaolongs/flutter-ho/d7e4bd24d5325aa896ea96725fc851044b003b00/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/zhaolongs/flutter-ho/d7e4bd24d5325aa896ea96725fc851044b003b00/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/zhaolongs/flutter-ho/d7e4bd24d5325aa896ea96725fc851044b003b00/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/zhaolongs/flutter-ho/d7e4bd24d5325aa896ea96725fc851044b003b00/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/zhaolongs/flutter-ho/d7e4bd24d5325aa896ea96725fc851044b003b00/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/zhaolongs/flutter-ho/d7e4bd24d5325aa896ea96725fc851044b003b00/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/zhaolongs/flutter-ho/d7e4bd24d5325aa896ea96725fc851044b003b00/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/zhaolongs/flutter-ho/d7e4bd24d5325aa896ea96725fc851044b003b00/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/zhaolongs/flutter-ho/d7e4bd24d5325aa896ea96725fc851044b003b00/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/zhaolongs/flutter-ho/d7e4bd24d5325aa896ea96725fc851044b003b00/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhaolongs/flutter-ho/d7e4bd24d5325aa896ea96725fc851044b003b00/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhaolongs/flutter-ho/d7e4bd24d5325aa896ea96725fc851044b003b00/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 Ho 9 | CFBundleExecutable 10 | $(EXECUTABLE_NAME) 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | flutter_ho 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 | 47 | 48 | -------------------------------------------------------------------------------- /ios/Runner/main.m: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | #import "AppDelegate.h" 4 | 5 | int main(int argc, char* argv[]) { 6 | @autoreleasepool { 7 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /lib/main.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_ho/src/root_app_page.dart'; 3 | 4 | void main() { 5 | runApp(RootAPP()); 6 | } 7 | -------------------------------------------------------------------------------- /lib/src/bean/bean_art.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_ho/src/bean/bean_user.dart'; 2 | 3 | /// 创建人: Created by zhaolong 4 | /// 创建时间:Created by on 2020/12/23. 5 | /// 6 | /// 可关注公众号:我的大前端生涯 获取最新技术分享 7 | /// 可关注网易云课堂:https://study.163.com/instructor/1021406098.htm 8 | /// 可关注博客:https://blog.csdn.net/zl18603543572 9 | /// 10 | /// 代码清单 11 | ///代码清单 12 | class ArtBean { 13 | //文章标题 14 | String? artTitle; 15 | 16 | //文章简介 17 | String? artInfo; 18 | 19 | //喜欢个数 20 | int? likeCount; 21 | 22 | //评论个数 23 | int? pariseCount; 24 | 25 | //用户数据 26 | UserBean? userBean; 27 | 28 | //创建时间 29 | String? createTime; 30 | 31 | ///常用用于解析JSON数据 32 | ArtBean.fromMap(Map map) { 33 | this.artTitle = map["title"]; 34 | this.artInfo = map["artInfo"]; 35 | 36 | this.likeCount = map["readCount"]; 37 | this.pariseCount = map["pariseCount"]; 38 | this.createTime = map['createTime']; 39 | 40 | var bean = map["user"]; 41 | if (bean != null) { 42 | userBean = UserBean.fromMap(bean); 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /lib/src/bean/bean_demo.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | class DemoBean { 4 | String title = ''; 5 | String content = ''; 6 | String time = ''; 7 | Widget page; 8 | 9 | DemoBean.name( 10 | {required this.title, 11 | this.time = "", 12 | this.content = '', 13 | required this.page}); 14 | } 15 | -------------------------------------------------------------------------------- /lib/src/bean/bean_user.dart: -------------------------------------------------------------------------------- 1 | /// 创建人: Created by zhaolong 2 | /// 创建时间:Created by on 2020/12/23. 3 | /// 4 | /// 可关注公众号:我的大前端生涯 获取最新技术分享 5 | /// 可关注网易云课堂:https://study.163.com/instructor/1021406098.htm 6 | /// 可关注博客:https://blog.csdn.net/zl18603543572 7 | /// 8 | /// 代码清单 9 | ///代码清单 10 | class UserBean { 11 | String userName = ""; 12 | int userAge = 0; 13 | 14 | ///常用用于解析JSON数据 15 | UserBean.fromMap(Map map) { 16 | this.userName = map["userName"]; 17 | this.userAge = map["age"]; 18 | } 19 | 20 | Map toJson() { 21 | final Map map = new Map(); 22 | map["userName"] = this.userName; 23 | map["age"] = this.userAge; 24 | return map; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /lib/src/bean/bean_version.dart: -------------------------------------------------------------------------------- 1 | /// 创建人: Created by zhaolong 2 | /// 创建时间:Created by on 2020/7/23. 3 | /// 4 | /// 创建人: Created by zhaolong 5 | /// 创建时间:Created by on 2020/9/25. 6 | /// 7 | /// gongzhonghao biglead 8 | /// https://study.163.com/instructor/1021406098.htm 9 | /// https://blog.csdn.net/zl18603543572 10 | /// https://www.toutiao.com/c/user/token/MS4wLjABAAAAYMrKikomuQJ4d-cPaeBqtAK2cQY697Pv9xIyyDhtwIM/ 11 | 12 | class AppVersionBean { 13 | bool isNeed = false; 14 | String isForce = "false"; 15 | String updateContent = ""; 16 | String packageUrl = ""; 17 | 18 | AppVersionBean.fromJson(Map map) { 19 | this.isNeed = map["isNeed"]; 20 | this.isForce = map["isForce"]; 21 | this.updateContent = map["updateContent"]; 22 | this.packageUrl = map["packageUrl"]; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /lib/src/home_page.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/cupertino.dart'; 2 | import 'package:flutter/material.dart'; 3 | import 'package:flutter_ho/src/pages/home/home_item3_page.dart'; 4 | import 'package:flutter_ho/src/pages/home/home_item_page.dart'; 5 | 6 | import 'pages/demo/home_item_demo_page.dart'; 7 | import 'pages/mine/mine_main_page.dart'; 8 | 9 | /// 创建人: Created by zhaolong 10 | /// 创建时间:Created by on 2020/12/14. 11 | /// 12 | /// 可关注公众号:我的大前端生涯 获取最新技术分享 13 | /// 可关注网易云课堂:https://study.163.com/instructor/1021406098.htm 14 | /// 可关注博客:https://blog.csdn.net/zl18603543572 15 | /// 16 | /// 代码清单 17 | ///首页面 18 | class HomePage extends StatefulWidget { 19 | @override 20 | _HomePageState createState() => _HomePageState(); 21 | } 22 | 23 | class _HomePageState extends State { 24 | //当前选中的标识 25 | int _currentIndex = 0; 26 | 27 | PageController _pageController = new PageController(); 28 | 29 | @override 30 | Widget build(BuildContext context) { 31 | return Scaffold( 32 | body: Container( 33 | width: double.infinity, 34 | height: double.infinity, 35 | child: PageView( 36 | controller: _pageController, 37 | //不可左右滑动 38 | physics: NeverScrollableScrollPhysics(), 39 | children: [ 40 | //第一个视频列表播放页面 41 | HomeItemPage(1), 42 | //第二个视频列表播放页面 43 | HomeItemDemoPage(), 44 | //第三个视频列表播放页面 45 | HomeItemPage(2), 46 | //第四个文章列表页面 47 | HomeItem3Page(), 48 | //第五个个人中心页面 49 | MineMainPage(), 50 | ], 51 | ), 52 | ), 53 | bottomNavigationBar: BottomNavigationBar( 54 | //当前选中的Item 默认为 0 55 | currentIndex: _currentIndex, 56 | //点击回调 57 | onTap: (int value) { 58 | setState(() { 59 | _currentIndex = value; 60 | _pageController.jumpToPage(value); 61 | }); 62 | }, 63 | //显示文字 64 | type: BottomNavigationBarType.fixed, 65 | //选中的颜色 66 | selectedItemColor: Colors.redAccent, 67 | //未选中颜色 68 | unselectedItemColor: Colors.blueGrey, 69 | items: [ 70 | BottomNavigationBarItem(icon: Icon(Icons.home), label: "首页"), 71 | BottomNavigationBarItem(icon: Icon(Icons.menu), label: "DEMO"), 72 | BottomNavigationBarItem(icon: Icon(Icons.five_g), label: "发现"), 73 | BottomNavigationBarItem(icon: Icon(Icons.message), label: "消息"), 74 | BottomNavigationBarItem(icon: Icon(Icons.person), label: "我的"), 75 | ], 76 | ), 77 | ); 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /lib/src/net/http_helper.dart: -------------------------------------------------------------------------------- 1 | /// 创建人: Created by zhaolong 2 | /// 创建时间:Created by on 2020/12/3. 3 | /// 4 | /// 可关注公众号:我的大前端生涯 获取最新技术分享 5 | /// 可关注网易云课堂:https://study.163.com/instructor/1021406098.htm 6 | /// 可关注博客:https://blog.csdn.net/zl18603543572 7 | /// 8 | /// 代码清单 9 | ///代码清单 10 | class HttpHelper { 11 | static const String BASE_HOST = "http://192.168.40.50:8080/"; 12 | //用户密码登录 13 | static const String login = BASE_HOST + "user/login"; 14 | //检查更新 15 | static const String appVersion = BASE_HOST + "app/version"; 16 | //获取文章列表 17 | static const String artList = BASE_HOST + "article/list"; 18 | } 19 | -------------------------------------------------------------------------------- /lib/src/net/log_interceptor.dart: -------------------------------------------------------------------------------- 1 | import 'package:dio/dio.dart'; 2 | 3 | /* 4 | * 创建人: zhaollong 5 | * 创建时间:2019-09-02 6 | * 页面说明:dio 网络请求拦截日志 7 | * 功能性修改记录: 8 | */ 9 | class LogsInterceptors extends InterceptorsWrapper { 10 | @override 11 | void onRequest( 12 | RequestOptions options, 13 | RequestInterceptorHandler handler, 14 | ) { 15 | super.onRequest(options, handler); 16 | print("\n================== 请求数据 =========================="); 17 | print("|请求url:${options.path}"); 18 | print('|请求头: ' + options.headers.toString()); 19 | print('|请求参数: ' + options.queryParameters.toString()); 20 | print('|请求方法: ' + options.method); 21 | print("|contentType = ${options.contentType}"); 22 | print('|请求时间: ' + DateTime.now().toString()); 23 | if (options.data != null) { 24 | print('|请求数据: ' + options.data.toString()); 25 | } 26 | } 27 | 28 | @override 29 | onResponse( 30 | Response response, 31 | ResponseInterceptorHandler handler, 32 | ) { 33 | super.onResponse(response, handler); 34 | print("\n|================== 响应数据 =========================="); 35 | if (response != null) { 36 | print("|url = ${response.realUri.path}"); 37 | print("|code = ${response.statusCode}"); 38 | print("|data = ${response.data}"); 39 | print('|返回时间: ' + DateTime.now().toString()); 40 | print("\n"); 41 | } else { 42 | print("|data = 请求错误 E409"); 43 | print('|返回时间: ' + DateTime.now().toString()); 44 | print("\n"); 45 | } 46 | } 47 | 48 | @override 49 | onError( 50 | DioError e, 51 | ErrorInterceptorHandler handler, 52 | ) { 53 | super.onError(e, handler); 54 | print("\n================== 错误响应数据 ======================"); 55 | print("|type = ${e.type}"); 56 | print("|message = ${e.message}"); 57 | 58 | print('|response = ${e.response}'); 59 | print("\n"); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /lib/src/pages/common/common_webview.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/cupertino.dart'; 2 | import 'package:flutter/material.dart'; 3 | import 'package:webview_flutter/webview_flutter.dart'; 4 | 5 | /// 创建人: Created by zhaolong 6 | /// 创建时间:Created by on 2020/12/12. 7 | /// 8 | /// 可关注公众号:我的大前端生涯 获取最新技术分享 9 | /// 可关注网易云课堂:https://study.163.com/instructor/1021406098.htm 10 | /// 可关注博客:https://blog.csdn.net/zl18603543572 11 | /// 12 | /// 代码清单 13 | ///代码清单 14 | class CommonWebViewPage extends StatefulWidget { 15 | final String htmlUrl; 16 | final String pageTitle; 17 | 18 | CommonWebViewPage({required this.htmlUrl, this.pageTitle = ""}); 19 | 20 | @override 21 | _CommonWebViewPageState createState() => _CommonWebViewPageState(); 22 | } 23 | 24 | class _CommonWebViewPageState extends State { 25 | @override 26 | Widget build(BuildContext context) { 27 | return Scaffold( 28 | appBar: AppBar( 29 | title: Text("${widget.pageTitle}"), 30 | ), 31 | backgroundColor: Colors.white, 32 | body: WebView( 33 | initialUrl: widget.htmlUrl, 34 | ), 35 | ); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /lib/src/pages/common/controller.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | 3 | 4 | /// 创建人: Created by zhaolong 5 | /// 创建时间:Created by on 2020/12/27. 6 | /// 7 | /// 可关注公众号:我的大前端生涯 获取最新技术分享 8 | /// 可关注网易云课堂:https://study.163.com/instructor/1021406098.htm 9 | /// 可关注博客:https://blog.csdn.net/zl18603543572 10 | /// 11 | //用于登录的通信 12 | StreamController loginStreamController = StreamController.broadcast(); 13 | -------------------------------------------------------------------------------- /lib/src/pages/common/user_helper.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_ho/src/bean/bean_user.dart'; 2 | import 'package:flutter_ho/src/utils/sp_utils.dart'; 3 | 4 | /// 创建人: Created by zhaolong 5 | /// 创建时间:Created by on 2020/12/23. 6 | /// 7 | /// 可关注公众号:我的大前端生涯 获取最新技术分享 8 | /// 可关注网易云课堂:https://study.163.com/instructor/1021406098.htm 9 | /// 可关注博客:https://blog.csdn.net/zl18603543572 10 | /// 11 | /// 代码清单 12 | ///代码清单 13 | class UserHepler { 14 | //私有化构造函数 15 | UserHepler._() {} 16 | 17 | //创建全局单例对象 18 | static UserHepler getInstance = UserHepler._(); 19 | 20 | UserBean? _userBean; 21 | 22 | //是否登录 23 | bool get isLogin => _userBean != null; 24 | 25 | set userBean(UserBean bean) { 26 | _userBean = bean; 27 | SPUtil.saveObject("user_bean", _userBean); 28 | } 29 | 30 | void init() { 31 | Map? map = SPUtil.getObject("user_bean"); 32 | if (map != null) { 33 | //加载缓存 34 | _userBean = UserBean.fromMap(map); 35 | } 36 | } 37 | 38 | void clear() { 39 | _userBean = null; 40 | SPUtil.remove("user_bean"); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /lib/src/pages/demo/demo1/demo_image_scan_main_page.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/cupertino.dart'; 2 | import 'package:flutter/material.dart'; 3 | import 'package:flutter_ho/src/utils/navigator_utils.dart'; 4 | 5 | import 'image_scan_widget.dart'; 6 | 7 | /// 创建人: Created by zhaolong 8 | /// 创建时间:Created by on 2021/1/11. 9 | /// 10 | /// 可关注公众号:我的大前端生涯 获取最新技术分享 11 | /// 可关注网易云课堂:https://study.163.com/instructor/1021406098.htm 12 | /// 可关注博客:https://blog.csdn.net/zl18603543572 13 | /// 14 | /// 代码清单 15 | ///代码清单 16 | /// 17 | main() { 18 | runApp(MaterialApp( 19 | debugShowCheckedModeBanner: false, 20 | home: DemoImageScanPage(), 21 | )); 22 | } 23 | 24 | class DemoImageScanPage extends StatefulWidget { 25 | @override 26 | _DemoPiePageState createState() => _DemoPiePageState(); 27 | } 28 | 29 | class _DemoPiePageState extends State { 30 | @override 31 | Widget build(BuildContext context) { 32 | return Scaffold( 33 | backgroundColor: Colors.white, 34 | appBar: AppBar( 35 | title: Text("图片浏览器"), 36 | centerTitle: true, 37 | ), 38 | //添加一个点击事件 39 | body: Center( 40 | child: InkWell( 41 | child: Image.asset("assets/images/banner1.png"), 42 | //点击回调 43 | onTap: () { 44 | //定义图片数组 45 | List imageList = [ 46 | "assets/images/banner1.png", 47 | "assets/images/banner2.png", 48 | "assets/images/banner1.png", 49 | "assets/images/banner2.png", 50 | ]; 51 | //打开一个新的页页 图片滑动浏览 52 | NavigatorUtils.pushPageByFade( 53 | context: context, 54 | targPage: ImageScanWidget(imageList:imageList), 55 | ); 56 | }, 57 | ), 58 | ), 59 | ); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /lib/src/pages/demo/demo1/targ_image_page.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/cupertino.dart'; 2 | import 'package:flutter/material.dart'; 3 | 4 | 5 | /// 创建人: Created by zhaolong 6 | /// 创建时间:Created by on 2021/1/25. 7 | /// 8 | /// 可关注公众号:我的大前端生涯 获取最新技术分享 9 | /// 可关注网易云课堂:https://study.163.com/instructor/1021406098.htm 10 | /// 可关注博客:https://blog.csdn.net/zl18603543572 11 | /// 12 | /// 代码清单 13 | ///代码清单 14 | class TagImagePage extends StatefulWidget { 15 | @override 16 | _TagImagePageState createState() => _TagImagePageState(); 17 | } 18 | 19 | class _TagImagePageState extends State { 20 | 21 | @override 22 | Widget build(BuildContext context) { 23 | return Scaffold( 24 | appBar: AppBar( 25 | title: Text("目标页面"), 26 | ), 27 | backgroundColor: Colors.blueGrey, 28 | 29 | ///填充布局 30 | body: Container( 31 | width: double.infinity, 32 | height: double.infinity, 33 | child: Column( 34 | children: [ 35 | ], 36 | )), 37 | ); 38 | } 39 | 40 | } -------------------------------------------------------------------------------- /lib/src/pages/demo/demo10/segment_demo.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/cupertino.dart'; 2 | import 'package:flutter/material.dart'; 3 | 4 | /// 创建人: Created by zhaolong 5 | /// 创建时间:Created by on 3/17/21. 6 | /// 7 | /// 可关注公众号:我的大前端生涯 获取最新技术分享 8 | /// 可关注网易云课堂:https://study.163.com/instructor/1021406098.htm 9 | /// 可关注博客:https://blog.csdn.net/zl18603543572 10 | /// 11 | /// 代码清单 12 | main() { 13 | runApp(MaterialApp( 14 | debugShowCheckedModeBanner: false, 15 | home: SegmentPage(), 16 | )); 17 | } 18 | 19 | class SegmentPage extends StatefulWidget { 20 | @override 21 | State createState() { 22 | return _SegmentPageState(); 23 | } 24 | } 25 | 26 | class _SegmentPageState extends State { 27 | @override 28 | Widget build(BuildContext context) { 29 | return Scaffold( 30 | appBar: AppBar( 31 | title: Text("分段控件"), 32 | ), 33 | 34 | ///填充布局 35 | body: Container( 36 | width: MediaQuery.of(context).size.width, 37 | height: double.infinity, 38 | child: Column( 39 | children: [ 40 | SizedBox( 41 | height: 3, 42 | ), 43 | // buildSegment(), 44 | buildSlidSegment(), 45 | ], 46 | ), 47 | ), 48 | ); 49 | } 50 | 51 | buildSegment() { 52 | return CupertinoSegmentedControl( 53 | //子标签 54 | children: { 55 | 0: Text("全部"), 56 | 1: Text("收入"), 57 | 2: Text("支出 "), 58 | }, 59 | //当前选中的索引 60 | groupValue: _currentIndex, 61 | //点击回调 62 | onValueChanged: (int index) { 63 | print("当前选中 $index"); 64 | setState(() { 65 | _currentIndex = index; 66 | }); 67 | }, 68 | //选中的背景颜色 69 | selectedColor: Colors.blue, 70 | //未选中的背景颜色 71 | unselectedColor: Colors.white, 72 | //边框颜色 73 | borderColor: Colors.blue, 74 | //按下的颜色 75 | pressedColor: Colors.blue.withOpacity(0.4), 76 | ); 77 | } 78 | 79 | //当前选中的索引 80 | int _currentIndex = 0; 81 | 82 | buildSlidSegment() { 83 | return Container( 84 | margin: EdgeInsets.only(top: 80), 85 | width: 300, 86 | child: CupertinoSlidingSegmentedControl( 87 | //子标签 88 | children: { 89 | 0: Text("全部"), 90 | 1: Text("收入"), 91 | 2: Text("支出 "), 92 | }, 93 | //当前选中的索引 94 | groupValue: _currentIndex, 95 | //点击回调 96 | onValueChanged: (int? index) { 97 | print("当前选中 $index"); 98 | setState(() { 99 | _currentIndex = index ?? 0; 100 | }); 101 | }, 102 | ), 103 | ); 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /lib/src/pages/demo/demo11/tooltips_demo.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/cupertino.dart'; 2 | import 'package:flutter/material.dart'; 3 | 4 | /// 创建人: Created by zhaolong 5 | /// 创建时间:Created by on 3/17/21. 6 | /// 7 | /// 可关注公众号:我的大前端生涯 获取最新技术分享 8 | /// 可关注网易云课堂:https://study.163.com/instructor/1021406098.htm 9 | /// 可关注博客:https://blog.csdn.net/zl18603543572 10 | /// 11 | /// 代码清单 12 | main() { 13 | runApp(MaterialApp( 14 | debugShowCheckedModeBanner: false, 15 | home: TipsDemoPage(), 16 | )); 17 | } 18 | 19 | class TipsDemoPage extends StatefulWidget { 20 | @override 21 | State createState() { 22 | return _TipsDemoPageState(); 23 | } 24 | } 25 | 26 | class _TipsDemoPageState extends State { 27 | @override 28 | Widget build(BuildContext context) { 29 | return Scaffold( 30 | appBar: AppBar( 31 | title: Text("控件"), 32 | ), 33 | 34 | ///填充布局 35 | body: Container( 36 | width: MediaQuery.of(context).size.width, 37 | height: double.infinity, 38 | child: Column( 39 | mainAxisAlignment: MainAxisAlignment.center, 40 | children: [ 41 | Tooltip( 42 | message: "小提示", 43 | //true 显示在下面,false 显示在上面 44 | preferBelow: true, 45 | //显示的时间 46 | showDuration: Duration(seconds: 3), 47 | //内边距 48 | padding: EdgeInsets.only(left: 20, right: 20), 49 | //垂直偏移 50 | verticalOffset: 10.0, 51 | decoration: BoxDecoration( 52 | border: Border.all(color: Colors.red), 53 | color: Colors.white, 54 | ), 55 | textStyle: TextStyle(color: Colors.blue), 56 | //外边距 57 | margin: EdgeInsets.only(top: 10, left: 60), 58 | child: ElevatedButton( 59 | onPressed: () {}, 60 | child: Text("想一想"), 61 | ), 62 | ) 63 | ], 64 | ), 65 | ), 66 | ); 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /lib/src/pages/demo/demo11/tooltips_demo2.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/cupertino.dart'; 2 | import 'package:flutter/material.dart'; 3 | 4 | /// 创建人: Created by zhaolong 5 | /// 创建时间:Created by on 3/17/21. 6 | /// 7 | /// 可关注公众号:我的大前端生涯 获取最新技术分享 8 | /// 可关注网易云课堂:https://study.163.com/instructor/1021406098.htm 9 | /// 可关注博客:https://blog.csdn.net/zl18603543572 10 | /// 11 | /// 代码清单 12 | main() { 13 | runApp(MaterialApp( 14 | debugShowCheckedModeBanner: false, 15 | home: TipsDemoPage(), 16 | )); 17 | } 18 | 19 | class TipsDemoPage extends StatefulWidget { 20 | @override 21 | State createState() { 22 | return _TipsDemoPageState(); 23 | } 24 | } 25 | 26 | class _TipsDemoPageState extends State { 27 | @override 28 | Widget build(BuildContext context) { 29 | return Scaffold( 30 | appBar: AppBar( 31 | title: Text("控件"), 32 | ), 33 | 34 | ///填充布局 35 | body: Container( 36 | width: MediaQuery.of(context).size.width, 37 | height: double.infinity, 38 | child: Column( 39 | mainAxisAlignment: MainAxisAlignment.center, 40 | children: [ 41 | Tooltip( 42 | message: "小提示", 43 | //true 显示在下面,false 显示在上面 44 | preferBelow: true, 45 | //显示的时间 46 | showDuration: Duration(seconds: 3), 47 | //内边距 48 | padding: EdgeInsets.only(left: 20, right: 20), 49 | //垂直偏移 50 | verticalOffset: 10.0, 51 | decoration: BoxDecoration( 52 | border: Border.all(color: Colors.red), 53 | color: Colors.white, 54 | ), 55 | textStyle: TextStyle(color: Colors.blue), 56 | //外边距 57 | margin: EdgeInsets.only(top: 10, left: 60), 58 | child: ElevatedButton( 59 | onPressed: () {}, 60 | child: Text("想一想"), 61 | ), 62 | ) 63 | ], 64 | ), 65 | ), 66 | ); 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /lib/src/pages/demo/demo16/demo_ConnectivityPage.dart: -------------------------------------------------------------------------------- 1 | // 2 | // import 'package:flutter/cupertino.dart'; 3 | // import 'package:flutter/material.dart'; 4 | // 5 | // /// 创建人: Created by zhaolong 6 | // /// 创建时间:Created by on 3/26/21. 7 | // /// 8 | // /// 可关注公众号:我的大前端生涯 获取最新技术分享 9 | // /// 可关注网易云课堂:https://study.163.com/instructor/1021406098.htm 10 | // /// 可关注博客:https://blog.csdn.net/zl18603543572 11 | // /// 12 | // main() { 13 | // runApp(MaterialApp( 14 | // debugShowCheckedModeBanner: false, 15 | // home: DemoConnectivityPage(), 16 | // )); 17 | // } 18 | // 19 | // ///代码清单 20 | // class DemoConnectivityPage extends StatefulWidget { 21 | // @override 22 | // _DemoConnectivityPageState createState() => _DemoConnectivityPageState(); 23 | // } 24 | // 25 | // class BottomNavigationWidget extends StatefulWidget { 26 | // @override 27 | // State createState() => _DemoConnectivityPageState(); 28 | // } 29 | // 30 | // class _DemoConnectivityPageState extends State { 31 | // @override 32 | // void initState() { 33 | // super.initState(); 34 | // //获取网络连接 35 | // isConnectedType(); 36 | // //设置个监听 37 | // connectLiserner(); 38 | // } 39 | // 40 | // @override 41 | // Widget build(BuildContext context) { 42 | // return Scaffold( 43 | // appBar: AppBar( 44 | // title: Text("网络连接"), 45 | // ), 46 | // body: Center( 47 | // child: Text("当前网络连接为 $_netType"), 48 | // ), 49 | // ); 50 | // } 51 | // 52 | // //判断是否联网 53 | // Future isConnected() async { 54 | // var connectivityResult = await (Connectivity().checkConnectivity()); 55 | // return connectivityResult != ConnectivityResult.none; 56 | // } 57 | // 58 | // //获取网络类型 59 | // late String _netType; 60 | // 61 | // void isConnectedType() async { 62 | // //获取网络连接类型 63 | // ConnectivityResult connectivityResult = 64 | // await (Connectivity().checkConnectivity()); 65 | // 66 | // if (connectivityResult == ConnectivityResult.mobile) { 67 | // // 网络类型为移动网络 68 | // _netType = "4G"; 69 | // } else if (connectivityResult == ConnectivityResult.wifi) { 70 | // // 网络类型为WIFI 71 | // _netType = "WIFI"; 72 | // } else { 73 | // _netType = "未联接"; 74 | // } 75 | // setState(() {}); 76 | // } 77 | // 78 | // //添加网络切换监听 79 | // void connectLiserner() async { 80 | // //获取Stream 81 | // Stream resultStream = 82 | // Connectivity().onConnectivityChanged; 83 | // //添加监听 84 | // resultStream.listen((ConnectivityResult result) { 85 | // // 86 | // print("有变化 ${result}"); 87 | // }); 88 | // } 89 | // } 90 | -------------------------------------------------------------------------------- /lib/src/pages/demo/demo17/demo_DateRangPage.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/cupertino.dart'; 2 | import 'package:flutter/material.dart'; 3 | import 'package:flutter_localizations/flutter_localizations.dart'; 4 | 5 | /// 创建人: Created by zhaolong 6 | /// 创建时间:Created by on 3/26/21. 7 | /// 8 | /// 可关注公众号:我的大前端生涯 获取最新技术分享 9 | /// 可关注网易云课堂:https://study.163.com/instructor/1021406098.htm 10 | /// 可关注博客:https://blog.csdn.net/zl18603543572 11 | /// 12 | main() { 13 | runApp(MaterialApp( 14 | //不显示 debug标签 15 | debugShowCheckedModeBanner: false, 16 | //当前运行环境配置 17 | locale: Locale("zh", "CH"), 18 | //程序支持的语言环境配置 19 | supportedLocales: [Locale("zh", "CH")], 20 | //Material 风格代理配置 21 | localizationsDelegates: [ 22 | GlobalMaterialLocalizations.delegate, 23 | GlobalWidgetsLocalizations.delegate, 24 | ], 25 | //显示的首页面 26 | home: DemoDateRangPage(), 27 | )); 28 | } 29 | 30 | ///代码清单 31 | class DemoDateRangPage extends StatefulWidget { 32 | @override 33 | _DemoDateRangPageState createState() => _DemoDateRangPageState(); 34 | } 35 | 36 | class _DemoDateRangPageState extends State { 37 | late String _dateSelectText; 38 | 39 | @override 40 | Widget build(BuildContext context) { 41 | return Scaffold( 42 | appBar: AppBar( 43 | title: Text("日期范围选择"), 44 | ), 45 | body: Center( 46 | child: Text("当前选择 $_dateSelectText"), 47 | ), 48 | floatingActionButton: FloatingActionButton( 49 | onPressed: () { 50 | showDateSelect(); 51 | }, 52 | child: Icon(Icons.select_all), 53 | ), 54 | ); 55 | } 56 | 57 | void showDateSelect() async { 58 | //获取当前的时间 59 | DateTime start = DateTime.now(); 60 | //在当前的时间上多添加4天 61 | DateTime end = DateTime(start.year, start.month, start.day + 4); 62 | 63 | //显示时间选择器 64 | DateTimeRange? selectTimeRange = await showDateRangePicker( 65 | //语言环境 66 | locale: Locale("zh", "CH"), 67 | context: context, 68 | //开始时间 69 | firstDate: DateTime(2020, 1), 70 | //结束时间 71 | lastDate: DateTime(2022, 1), 72 | cancelText: "取消", 73 | confirmText: "确定", 74 | //初始的时间范围选择 75 | initialDateRange: DateTimeRange(start: start, end: end)); 76 | if (selectTimeRange != null) { 77 | //结果 78 | _dateSelectText = selectTimeRange.toString(); 79 | //选择结果中的开始时间 80 | DateTime selectStart = selectTimeRange.start; 81 | //选择结果中的结束时间 82 | DateTime selectEnd = selectTimeRange.end; 83 | 84 | setState(() {}); 85 | } 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /lib/src/pages/demo/demo19/demo_WillPopScope.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/cupertino.dart'; 2 | import 'package:flutter/material.dart'; 3 | 4 | /// 创建人: Created by zhaolong 5 | /// 创建时间:Created by on 3/26/21. 6 | /// 7 | /// 可关注公众号:我的大前端生涯 获取最新技术分享 8 | /// 可关注网易云课堂:https://study.163.com/instructor/1021406098.htm 9 | /// 可关注博客:https://blog.csdn.net/zl18603543572 10 | /// 11 | main() { 12 | runApp(MaterialApp( 13 | //不显示 debug标签 14 | debugShowCheckedModeBanner: false, 15 | //显示的首页面 16 | home: DemoWillPopScope(), 17 | )); 18 | } 19 | 20 | ///代码清单 21 | class DemoWillPopScope extends StatefulWidget { 22 | @override 23 | _DemoWillPopScopeState createState() => _DemoWillPopScopeState(); 24 | } 25 | 26 | class _DemoWillPopScopeState extends State { 27 | //上一次点击事件 28 | int pretime = 0; 29 | 30 | @override 31 | Widget build(BuildContext context) { 32 | //返回 或者说退出页面里的提示 33 | return WillPopScope( 34 | onWillPop: () async { 35 | print("返回"); 36 | //当前时间 37 | int now = DateTime.now().millisecond; 38 | //计算时间差 39 | int flag = now - pretime; 40 | //两次点击时间太长不做处理 41 | if (flag > 1000) { 42 | print("返回1"); 43 | pretime = now; 44 | return false; 45 | } 46 | print("返回2"); 47 | showTips(); 48 | //拦截 49 | return false; 50 | }, 51 | child: Scaffold( 52 | appBar: AppBar( 53 | title: Text("拦截返回按钮"), 54 | ), 55 | body: Container( 56 | padding: EdgeInsets.all(30), 57 | child: Column( 58 | children: [], 59 | ), 60 | ), 61 | ), 62 | ); 63 | } 64 | 65 | void showTips() async { 66 | bool? flag = await showDialog( 67 | context: context, 68 | builder: (BuildContext context) { 69 | return new AlertDialog( 70 | title: Text("提示"), 71 | content: Text("您确定要退出吗???"), 72 | actions: [ 73 | TextButton( 74 | onPressed: () { 75 | Navigator.of(context).pop(true); 76 | }, 77 | child: Text("确定")), 78 | TextButton( 79 | onPressed: () { 80 | Navigator.of(context).pop(false); 81 | }, 82 | child: Text("取消")) 83 | ], 84 | ); 85 | }); 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /lib/src/pages/demo/demo2/list_main_demo.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/cupertino.dart'; 2 | import 'package:flutter/material.dart'; 3 | import 'package:flutter_ho/src/pages/demo/demo2/list_demo2_item_widget.dart'; 4 | 5 | /// 创建人: Created by zhaolong 6 | /// 创建时间:Created by on 2021/1/27. 7 | /// 8 | /// 可关注公众号:我的大前端生涯 获取最新技术分享 9 | /// 可关注网易云课堂:https://study.163.com/instructor/1021406098.htm 10 | /// 可关注博客:https://blog.csdn.net/zl18603543572 11 | /// 12 | main() { 13 | runApp( 14 | MaterialApp( 15 | home: ListDemo2Page(), 16 | ), 17 | ); 18 | } 19 | 20 | ///代码清单 21 | class ListDemo2Page extends StatefulWidget { 22 | @override 23 | _ListDemo2PageState createState() => _ListDemo2PageState(); 24 | } 25 | 26 | class _ListDemo2PageState extends State { 27 | @override 28 | Widget build(BuildContext context) { 29 | return Scaffold( 30 | appBar: AppBar( 31 | title: Text("测试Demo"), 32 | ), 33 | backgroundColor: Colors.white, 34 | // Alt + 回车键提示 35 | //Ctrl + Alt + L 格式化代码 36 | //Ctrl + E 显示最近编辑的文件列表 37 | body: ListView.builder( 38 | //条目个数 39 | itemCount: 10, 40 | //每个子条目的样式 41 | itemBuilder: (BuildContext context, int index) { 42 | return ListViewDemo2Item(index: index,); 43 | }, 44 | ), 45 | ); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /lib/src/pages/demo/demo21/demo_StreamBuilder.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | 3 | import 'package:flutter/cupertino.dart'; 4 | import 'package:flutter/material.dart'; 5 | 6 | /// 创建人: Created by zhaolong 7 | /// 创建时间:Created by on 3/26/21. 8 | /// 9 | /// 可关注公众号:我的大前端生涯 获取最新技术分享 10 | /// 可关注网易云课堂:https://study.163.com/instructor/1021406098.htm 11 | /// 可关注博客:https://blog.csdn.net/zl18603543572 12 | /// 13 | main() { 14 | runApp(MaterialApp( 15 | //不显示 debug标签 16 | debugShowCheckedModeBanner: false, 17 | //显示的首页面 18 | home: DemoStreamBuilder(), 19 | )); 20 | } 21 | 22 | ///代码清单 23 | class DemoStreamBuilder extends StatefulWidget { 24 | @override 25 | _DemoStreamBuilderState createState() => _DemoStreamBuilderState(); 26 | } 27 | 28 | class _DemoStreamBuilderState extends State { 29 | 30 | int _count = 0; 31 | //流Stream 控制器 32 | StreamController _streamController = StreamController(); 33 | 34 | @override 35 | void dispose() { 36 | //销毁 37 | _streamController.close(); 38 | super.dispose(); 39 | } 40 | 41 | @override 42 | Widget build(BuildContext context) { 43 | // 44 | return Scaffold( 45 | floatingActionButton: FloatingActionButton( 46 | child: Icon(Icons.add), 47 | onPressed: () { 48 | _count++; 49 | //发送消息 50 | _streamController.add(_count); 51 | }, 52 | ), 53 | appBar: AppBar( 54 | title: Text("StreamBuilder"), 55 | ), 56 | body: Container( 57 | padding: EdgeInsets.all(30), 58 | child: Column( 59 | children: [ 60 | //接收消息 61 | StreamBuilder( 62 | //初始值 63 | initialData: _count, 64 | //绑定Stream 65 | stream: _streamController.stream, 66 | builder: (BuildContext context, AsyncSnapshot snapshot) { 67 | return Text("测试使用 ${snapshot.data}"); 68 | }, 69 | ), 70 | 71 | Text("测试使用"), 72 | Text("测试使用"), 73 | ], 74 | ), 75 | ), 76 | ); 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /lib/src/pages/demo/demo23/demo_BackdropFiltert.dart: -------------------------------------------------------------------------------- 1 | import 'dart:ui'; 2 | 3 | import 'package:flutter/cupertino.dart'; 4 | import 'package:flutter/material.dart'; 5 | import 'package:flutter_ho/src/pages/demo/demo22/demo_LoadingWidget.dart'; 6 | 7 | /// 创建人: Created by zhaolong 8 | /// 创建时间:Created by on 3/26/21. 9 | /// 10 | /// 可关注公众号:我的大前端生涯 获取最新技术分享 11 | /// 可关注网易云课堂:https://study.163.com/instructor/1021406098.htm 12 | /// 可关注博客:https://blog.csdn.net/zl18603543572 13 | /// 14 | /// 15 | /// 16 | /// 17 | main() { 18 | runApp(MaterialApp( 19 | //不显示 debug标签 20 | debugShowCheckedModeBanner: false, 21 | //显示的首页面 22 | home: DemoBackdropFilterPage(), 23 | )); 24 | } 25 | 26 | ///代码清单 27 | class DemoBackdropFilterPage extends StatefulWidget { 28 | @override 29 | _DemoBackdropFilterPageState createState() => _DemoBackdropFilterPageState(); 30 | } 31 | 32 | class _DemoBackdropFilterPageState extends State { 33 | bool _isLoading = true; 34 | 35 | @override 36 | void initState() { 37 | // TODO: implement initState 38 | super.initState(); 39 | Future.delayed(Duration(seconds: 4), () { 40 | // _isLoading=false; 41 | setState(() { 42 | 43 | }); 44 | }); 45 | } 46 | 47 | @override 48 | Widget build(BuildContext context) { 49 | // 50 | return Scaffold( 51 | appBar: AppBar( 52 | title: Text("高斯模糊"), 53 | ), 54 | body: Container( 55 | width: double.infinity, 56 | height: double.infinity, 57 | child: Stack( 58 | //居中 59 | alignment: Alignment.center, 60 | children: [ 61 | Positioned.fill( 62 | child: Image.asset( 63 | "assets/images/sp05.png", 64 | fit: BoxFit.fitWidth, 65 | ), 66 | ), 67 | Positioned.fill( 68 | child: buildLoading(), 69 | ), 70 | ], 71 | ), 72 | ), 73 | ); 74 | } 75 | 76 | buildLoading() { 77 | if (!_isLoading) { 78 | return Container(); 79 | } 80 | return Stack( 81 | //居中 82 | alignment: Alignment.center, 83 | children: [ 84 | //高斯模糊层 85 | Positioned.fill( 86 | child: BackdropFilter( 87 | filter: ImageFilter.blur(sigmaX: 100), 88 | child: Container( 89 | color: Color(0x80ffffff), 90 | ), 91 | ), 92 | ), 93 | LoadingWidget( 94 | title: "加载中", 95 | ), 96 | ], 97 | ); 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /lib/src/pages/demo/demo24/demo_SelectImageWidget.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/cupertino.dart'; 2 | import 'package:flutter/material.dart'; 3 | 4 | import 'SelectPhotoWidget.dart'; 5 | 6 | /// 创建人: Created by zhaolong 7 | /// 创建时间:Created by on 3/26/21. 8 | /// 9 | /// 可关注公众号:我的大前端生涯 获取最新技术分享 10 | /// 可关注网易云课堂:https://study.163.com/instructor/1021406098.htm 11 | /// 可关注博客:https://blog.csdn.net/zl18603543572 12 | /// 13 | /// 14 | /// 15 | /// 16 | main() { 17 | runApp(MaterialApp( 18 | //不显示 debug标签 19 | debugShowCheckedModeBanner: false, 20 | //显示的首页面 21 | home: DemoSelectImageWidgetPage(), 22 | )); 23 | } 24 | 25 | ///代码清单 26 | class DemoSelectImageWidgetPage extends StatefulWidget { 27 | @override 28 | _DemoSelectImageWidgetPageState createState() => 29 | _DemoSelectImageWidgetPageState(); 30 | } 31 | 32 | class _DemoSelectImageWidgetPageState extends State { 33 | @override 34 | Widget build(BuildContext context) { 35 | // 36 | return Scaffold( 37 | backgroundColor: Colors.grey, 38 | appBar: AppBar(title: Text("图片选择组件")), 39 | body: Center( 40 | child: Container( 41 | padding: EdgeInsets.all(12), 42 | //图片选择组件 43 | child: SelectPhotoWidget( 44 | header: Text( 45 | "请选择照片", 46 | style: TextStyle(fontWeight: FontWeight.w600, fontSize: 18), 47 | ), 48 | //标题下的红色提醒文本 49 | tips: "请注意 最多选择5张图片", 50 | //图片选择回调 51 | imageSelectAction: (List list) { 52 | print("实时选择回调${list.toString()}"); 53 | }, 54 | //最大选择图片数据 55 | maxSelect: 6, 56 | //预设图片 57 | imageList: [], 58 | ), 59 | ), 60 | ), 61 | ); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /lib/src/pages/demo/demo27/a_widget.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | 3 | import 'package:flutter/cupertino.dart'; 4 | import 'package:flutter/material.dart'; 5 | 6 | import 'ab.dart'; 7 | 8 | /// 创建人: Created by zhaolong 9 | /// 创建时间:Created by on 3/26/21. 10 | /// 11 | /// 可关注公众号:我的大前端生涯 获取最新技术分享 12 | /// 可关注网易云课堂:https://study.163.com/instructor/1021406098.htm 13 | /// 可关注博客:https://blog.csdn.net/zl18603543572 14 | /// 15 | /// 16 | /// 17 | /// 18 | 19 | ///代码清单 20 | class AWidget extends StatefulWidget { 21 | @override 22 | _AWidgetState createState() => _AWidgetState(); 23 | } 24 | 25 | class _AWidgetState extends State { 26 | int _result = 0; 27 | late StreamSubscription _streamSubscription; 28 | @override 29 | void initState() { 30 | super.initState(); 31 | //设置一个监听 订阅一个监听 32 | _streamSubscription = abStreamController.stream.listen((event) { 33 | _result = event; 34 | setState(() {}); 35 | }); 36 | } 37 | 38 | @override 39 | void dispose() { 40 | //取消订阅 41 | _streamSubscription.cancel(); 42 | super.dispose(); 43 | } 44 | 45 | @override 46 | Widget build(BuildContext context) { 47 | // 48 | return Container( 49 | color: Colors.blue, 50 | child: Text("A中的数据 ${_result}"), 51 | ); 52 | } 53 | 54 | Container buildContainer() { 55 | return Container( 56 | color: Colors.blue, 57 | child: StreamBuilder( 58 | stream: abStreamController.stream, 59 | initialData: _result, 60 | builder: (BuildContext context, AsyncSnapshot snapshot) { 61 | _result = snapshot.data!; 62 | return Text("A中的数据 ${snapshot.data}"); 63 | }, 64 | ), 65 | ); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /lib/src/pages/demo/demo27/ab.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | 3 | StreamController abStreamController = StreamController.broadcast(); 4 | -------------------------------------------------------------------------------- /lib/src/pages/demo/demo27/b_widget.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/cupertino.dart'; 2 | import 'package:flutter/material.dart'; 3 | 4 | import 'ab.dart'; 5 | 6 | /// 创建人: Created by zhaolong 7 | /// 创建时间:Created by on 3/26/21. 8 | /// 9 | /// 可关注公众号:我的大前端生涯 获取最新技术分享 10 | /// 可关注网易云课堂:https://study.163.com/instructor/1021406098.htm 11 | /// 可关注博客:https://blog.csdn.net/zl18603543572 12 | /// 13 | /// 14 | /// 15 | /// 16 | 17 | ///代码清单 18 | class BWidget extends StatefulWidget { 19 | @override 20 | _BWidgetState createState() => _BWidgetState(); 21 | } 22 | 23 | class _BWidgetState extends State { 24 | int _result = 1; 25 | 26 | @override 27 | void dispose() { 28 | super.dispose(); 29 | } 30 | 31 | @override 32 | Widget build(BuildContext context) { 33 | // 34 | return Container( 35 | color: Colors.blue, 36 | child: Column( 37 | children: [ 38 | ElevatedButton( 39 | onPressed: () { 40 | _result++; 41 | //发送数据 42 | abStreamController.add(_result); 43 | }, 44 | child: StreamBuilder( 45 | stream: abStreamController.stream, 46 | initialData: _result, 47 | builder: (BuildContext context, AsyncSnapshot snapshot) { 48 | return Text("++ ${snapshot.data}"); 49 | }, 50 | ), 51 | ), 52 | ], 53 | ), 54 | ); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /lib/src/pages/demo/demo27/demo_Stream.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/cupertino.dart'; 2 | import 'package:flutter/material.dart'; 3 | 4 | import 'a_widget.dart'; 5 | import 'b_widget.dart'; 6 | 7 | /// 创建人: Created by zhaolong 8 | /// 创建时间:Created by on 3/26/21. 9 | /// 10 | /// 可关注公众号:我的大前端生涯 获取最新技术分享 11 | /// 可关注网易云课堂:https://study.163.com/instructor/1021406098.htm 12 | /// 可关注博客:https://blog.csdn.net/zl18603543572 13 | /// 14 | /// 15 | /// 16 | /// 17 | main() { 18 | runApp(MaterialApp( 19 | //不显示 debug标签 20 | debugShowCheckedModeBanner: false, 21 | //显示的首页面 22 | home: DemoStreamPage(), 23 | )); 24 | } 25 | 26 | ///代码清单 27 | class DemoStreamPage extends StatefulWidget { 28 | @override 29 | _DemoStreamPageState createState() => _DemoStreamPageState(); 30 | } 31 | 32 | class _DemoStreamPageState extends State { 33 | @override 34 | void dispose() { 35 | super.dispose(); 36 | } 37 | 38 | @override 39 | Widget build(BuildContext context) { 40 | // 41 | return Scaffold( 42 | backgroundColor: Colors.grey[200], 43 | appBar: AppBar( 44 | title: Text("Stream"), 45 | ), 46 | body: Container( 47 | width: double.infinity, 48 | padding: EdgeInsets.all(10), 49 | child: Column(children: [ 50 | Container( 51 | width: 300, 52 | height: 200, 53 | child: AWidget(), 54 | ), 55 | SizedBox( 56 | height: 22, 57 | ), 58 | Container( 59 | width: 300, 60 | height: 200, 61 | child: BWidget(), 62 | ), 63 | ]), 64 | ), 65 | ); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /lib/src/pages/demo/demo3/GridViewBean.dart: -------------------------------------------------------------------------------- 1 | /// 创建人: Created by zhaolong 2 | /// 创建时间:Created by on 2021/2/7. 3 | /// 4 | /// 可关注公众号:我的大前端生涯 获取最新技术分享 5 | /// 可关注网易云课堂:https://study.163.com/instructor/1021406098.htm 6 | /// 可关注博客:https://blog.csdn.net/zl18603543572 7 | /// 8 | 9 | class GridBean { 10 | String title; 11 | bool isSelect; 12 | 13 | GridBean({required this.title, this.isSelect = false}); 14 | } 15 | -------------------------------------------------------------------------------- /lib/src/pages/demo/demo3/GridViewItemWidget.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/cupertino.dart'; 2 | import 'package:flutter/material.dart'; 3 | 4 | import 'GridViewBean.dart'; 5 | 6 | /// 创建人: Created by zhaolong 7 | /// 创建时间:Created by on 2021/2/7. 8 | /// 9 | /// 可关注公众号:我的大前端生涯 获取最新技术分享 10 | /// 可关注网易云课堂:https://study.163.com/instructor/1021406098.htm 11 | /// 可关注博客:https://blog.csdn.net/zl18603543572 12 | /// 13 | /// 代码清单 14 | ///GridView使用的子Item 15 | class GridViewItemWidget extends StatefulWidget { 16 | final GridBean bean; 17 | 18 | const GridViewItemWidget({Key? key, required this.bean}) : super(key: key); 19 | 20 | @override 21 | _GridViewItemWidgetState createState() => _GridViewItemWidgetState(); 22 | } 23 | 24 | class _GridViewItemWidgetState extends State { 25 | @override 26 | Widget build(BuildContext context) { 27 | return Container( 28 | color: Colors.white, 29 | child: Stack( 30 | alignment: Alignment.center, 31 | children: [ 32 | Positioned( 33 | top: 6, 34 | bottom: 6, 35 | left: 10, 36 | right: 10, 37 | //点击事件 38 | child: GestureDetector( 39 | onTap: () { 40 | //相反取值 41 | widget.bean.isSelect = !widget.bean.isSelect; 42 | setState(() {}); 43 | }, 44 | child: buildContainer(), 45 | ), 46 | ) 47 | ], 48 | ), 49 | ); 50 | } 51 | 52 | Container buildContainer() { 53 | Color normalColor = Colors.grey[200]!; 54 | 55 | //如果是选中 56 | if (widget.bean.isSelect) { 57 | normalColor = Colors.redAccent; 58 | } 59 | 60 | return Container( 61 | //子Widget 居中 62 | alignment: Alignment.center, 63 | decoration: BoxDecoration( 64 | color: normalColor, 65 | borderRadius: BorderRadius.all( 66 | Radius.circular(22), 67 | ), 68 | ), 69 | child: buildText(), 70 | ); 71 | } 72 | 73 | buildText() { 74 | //字体颜色 75 | Color normalColor = Colors.black; 76 | 77 | //如果是选中 78 | if (widget.bean.isSelect) { 79 | normalColor = Colors.white; 80 | } 81 | 82 | return Text( 83 | "${widget.bean.title}", 84 | style: TextStyle(color: normalColor), 85 | ); 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /lib/src/pages/demo/demo30/demo_demo_Scaffold_01.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/cupertino.dart'; 2 | import 'package:flutter/material.dart'; 3 | 4 | /// 创建人: Created by zhaolong 5 | /// 创建时间:Created by on 3/26/21. 6 | /// 7 | /// 可关注公众号:我的大前端生涯 获取最新技术分享 8 | /// 可关注网易云课堂:https://study.163.com/instructor/1021406098.htm 9 | /// 可关注博客:https://blog.csdn.net/zl18603543572 10 | /// 11 | /// 12 | /// 13 | /// 14 | main() { 15 | runApp(MaterialApp( 16 | //不显示 debug标签 17 | debugShowCheckedModeBanner: false, 18 | //显示的首页面 19 | home: DemoScaffold01Page(), 20 | )); 21 | } 22 | 23 | ///代码清单 24 | class DemoScaffold01Page extends StatefulWidget { 25 | @override 26 | _DemoScaffold01PageState createState() => _DemoScaffold01PageState(); 27 | } 28 | 29 | class _DemoScaffold01PageState extends State { 30 | GlobalKey _globalKey = GlobalKey(); 31 | @override 32 | Widget build(BuildContext context) { 33 | ///使用 Scaffold 组件来构建应用的基本页面 34 | /// 页面的架构 35 | return Scaffold( 36 | ///定义页面的标题 37 | appBar: AppBar( 38 | title: Text("这里是首页"), 39 | ), 40 | 41 | ///定义的页面的主体内容 42 | ///定义的悬浮按钮 43 | floatingActionButton: FloatingActionButton( 44 | key: _globalKey, 45 | child: Text("++"), 46 | 47 | ///点击响应事 48 | onPressed: () { 49 | print("点击了 FloatingActionButton"); 50 | }, 51 | 52 | ///长按提示 53 | tooltip: "点击了 tooltip s ", 54 | 55 | ///设置悬浮按钮的背景 56 | backgroundColor: Colors.red, 57 | 58 | ///获取焦点时显示的颜色 59 | focusColor: Colors.green, 60 | 61 | ///鼠标悬浮在按钮上时显示的颜色 62 | hoverColor: Colors.yellow, 63 | 64 | ///水波纹颜色 65 | splashColor: Colors.deepPurple, 66 | 67 | ///定义前景色 主要影响文字的颜色 68 | foregroundColor: Colors.black, 69 | 70 | ///配制阴影高度 未点击时 71 | elevation: 0.0, 72 | 73 | ///配制阴影高度 点击时 74 | highlightElevation: 20.0, 75 | mini: true, 76 | ), 77 | 78 | ///用来控制 FloatingActionButton 的位置 79 | ///FloatingActionButtonLocation.endFloat 右下角 默认 浮动 80 | ///FloatingActionButtonLocation.endDocked 右下角 无浮动效果 无间隔 81 | ///FloatingActionButtonLocation.endTop 右上角 82 | /// 83 | /// FloatingActionButtonLocation.centerDocked 居中(底部)) 无浮动效果 无间隔 84 | /// FloatingActionButtonLocation.centerFloat 居中(底部) 浮动 85 | ///FloatingActionButtonLocation.centerTop 居中(顶部) 浮动 86 | /// 87 | /// FloatingActionButtonLocation.startTop 顶部 左对齐 88 | /// FloatingActionButtonLocation.startFloat 左下角 浮动 89 | /// FloatingActionButtonLocation.startFloat 左下角 不浮动 90 | 91 | floatingActionButtonLocation: FloatingActionButtonLocation.startFloat, 92 | ); 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /lib/src/pages/demo/demo31/Snake.dart: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /lib/src/pages/demo/demo31/demo_sensors_plus.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/cupertino.dart'; 2 | import 'package:flutter/material.dart'; 3 | import 'package:sensors_plus/sensors_plus.dart'; 4 | 5 | /// 创建人: Created by zhaolong 6 | /// 创建时间:Created by on 3/26/21. 7 | /// 8 | /// 可关注公众号:我的大前端生涯 获取最新技术分享 9 | /// 可关注网易云课堂:https://study.163.com/instructor/1021406098.htm 10 | /// 可关注博客:https://blog.csdn.net/zl18603543572 11 | /// 12 | /// 13 | /// 14 | /// 15 | main() { 16 | runApp(MaterialApp( 17 | //不显示 debug标签 18 | debugShowCheckedModeBanner: false, 19 | //显示的首页面 20 | home: DemoSensorsPlusPage(), 21 | )); 22 | } 23 | 24 | ///代码清单 25 | class DemoSensorsPlusPage extends StatefulWidget { 26 | @override 27 | _DemoSensorsPlusPageState createState() => _DemoSensorsPlusPageState(); 28 | } 29 | 30 | class _DemoSensorsPlusPageState extends State { 31 | bool _isShow = false; 32 | 33 | @override 34 | void initState() { 35 | super.initState(); 36 | 37 | //加速度 受重力影响 38 | accelerometerEvents.listen((AccelerometerEvent event) async { 39 | //[AccelerometerEvent (x: 0.0992431640625, y: 0.11407470703125, z: 9.776962280273438)] 40 | // print(event); 41 | int value = 10; 42 | if (event.x.abs() > value || 43 | event.y.abs() > value || 44 | event.z.abs() > value) { 45 | if (!_isShow) { 46 | _isShow = true; 47 | dynamic result = await showDialog( 48 | builder: (BuildContext context) { 49 | return CupertinoAlertDialog( 50 | title: Text("摇一摇"), 51 | content: Image.asset( 52 | "assets/images/banner1.png", 53 | width: 200, 54 | ), 55 | ); 56 | }, 57 | context: context, 58 | barrierDismissible: true); 59 | _isShow = false; 60 | } 61 | } 62 | }); 63 | 64 | //加速度 不受重力影响 65 | userAccelerometerEvents.listen((UserAccelerometerEvent event) {}); 66 | 67 | //陀螺仪传感器 68 | gyroscopeEvents.listen((GyroscopeEvent event) { 69 | //[GyroscopeEvent (x: 0.00042724609375, y: 0.0005340576171875, z: -0.0003204345703125)] 70 | // print(event); 71 | }); 72 | } 73 | 74 | @override 75 | Widget build(BuildContext context) { 76 | ///使用 Scaffold 组件来构建应用的基本页面 77 | /// 页面的架构 78 | return Scaffold( 79 | appBar: AppBar(title: Text("sensors_plus")), 80 | body: Center( 81 | child: Text("摇一摇"), 82 | ), 83 | ); 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /lib/src/pages/demo/demo32/demo_demo_Scaffold_01.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/cupertino.dart'; 2 | import 'package:flutter/material.dart'; 3 | 4 | import 'TimerPicker.dart'; 5 | 6 | /// 创建人: Created by zhaolong 7 | /// 创建时间:Created by on 3/26/21. 8 | /// 9 | /// 可关注公众号:我的大前端生涯 获取最新技术分享 10 | /// 可关注网易云课堂:https://study.163.com/instructor/1021406098.htm 11 | /// 可关注博客:https://blog.csdn.net/zl18603543572 12 | /// 13 | /// 14 | /// 15 | /// 16 | main() { 17 | runApp(MaterialApp( 18 | //不显示 debug标签 19 | debugShowCheckedModeBanner: false, 20 | //显示的首页面 21 | home: DemoScaffold01Page(), 22 | )); 23 | } 24 | 25 | ///代码清单 26 | class DemoScaffold01Page extends StatefulWidget { 27 | @override 28 | _DemoScaffold01PageState createState() => _DemoScaffold01PageState(); 29 | } 30 | 31 | class _DemoScaffold01PageState extends State { 32 | GlobalKey _globalKey = GlobalKey(); 33 | 34 | @override 35 | Widget build(BuildContext context) { 36 | if (_globalKey.currentContext != null) { 37 | BuildContext? ctx = _globalKey.currentContext; 38 | if (ctx != null) { 39 | RenderObject? renderObject = ctx.findRenderObject(); 40 | if (renderObject != null) { 41 | RenderObject _renderBox = renderObject; 42 | Offset centerRightOffset = _renderBox.paintBounds.bottomLeft; 43 | print("centerRightOffset $centerRightOffset"); 44 | } 45 | } 46 | } 47 | 48 | ///使用 Scaffold 组件来构建应用的基本页面 49 | /// 页面的架构 50 | return Scaffold( 51 | ///定义页面的标题 52 | appBar: AppBar( 53 | title: Text("这里是首页"), 54 | ), 55 | 56 | ///定义的页面的主体内容 57 | ///定义的悬浮按钮 58 | floatingActionButton: FloatingActionButton( 59 | key: _globalKey, 60 | child: Text("++"), 61 | 62 | ///点击响应事 63 | onPressed: () { 64 | showDialog( 65 | context: context, 66 | builder: (context) { 67 | return TimerPicker( 68 | callback: (a) async { 69 | print(a); 70 | }, 71 | ); 72 | }); 73 | }, 74 | ), 75 | ); 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /lib/src/pages/demo/demo33/demo_Align.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/cupertino.dart'; 2 | import 'package:flutter/material.dart'; 3 | 4 | /// 创建人: Created by zhaolong 5 | /// 创建时间:Created by on 3/26/21. 6 | /// 7 | /// 可关注公众号:我的大前端生涯 获取最新技术分享 8 | /// 可关注网易云课堂:https://study.163.com/instructor/1021406098.htm 9 | /// 可关注博客:https://blog.csdn.net/zl18603543572 10 | /// 11 | /// 12 | /// 13 | /// 14 | main() { 15 | runApp(MaterialApp( 16 | //不显示 debug标签 17 | debugShowCheckedModeBanner: false, 18 | //显示的首页面 19 | home: DemoAlignPage(), 20 | )); 21 | } 22 | 23 | ///代码清单 24 | class DemoAlignPage extends StatefulWidget { 25 | @override 26 | _DemoAlignPageState createState() => _DemoAlignPageState(); 27 | } 28 | 29 | class _DemoAlignPageState extends State { 30 | //对齐方式 31 | Alignment _alignment = Alignment.center; 32 | 33 | @override 34 | Widget build(BuildContext context) { 35 | return Scaffold( 36 | appBar: AppBar(title: Text("这里是首页")), 37 | body: Container( 38 | child: AnimatedAlign( 39 | alignment: _alignment, 40 | //动画曲线 41 | curve: Curves.bounceInOut, 42 | //动画执行完成 43 | onEnd: () { 44 | print("执行结束 "); 45 | }, 46 | duration: Duration(seconds: 2), 47 | child: Text( 48 | "早起的年轻人", 49 | style: TextStyle( 50 | fontWeight: FontWeight.w600, 51 | color: Colors.blueAccent, 52 | ), 53 | ), 54 | ), 55 | ), 56 | floatingActionButton: FloatingActionButton( 57 | child: Text("切换"), 58 | onPressed: () { 59 | _alignment = _alignment == Alignment.center 60 | ? Alignment.topCenter 61 | : Alignment.center; 62 | setState(() {}); 63 | }, 64 | ), 65 | ); 66 | } 67 | } 68 | 69 | class TestWidget extends StatelessWidget { 70 | @override 71 | Widget build(BuildContext context) { 72 | return Scaffold( 73 | appBar: AppBar(title: Text("这里是首页")), 74 | body: Container( 75 | child: Align( 76 | alignment: Alignment.center, 77 | child: Text( 78 | "早起的年轻人", 79 | style: TextStyle( 80 | fontWeight: FontWeight.w600, 81 | color: Colors.blueAccent, 82 | ), 83 | ), 84 | ), 85 | ), 86 | floatingActionButton: FloatingActionButton( 87 | child: Text("切换"), 88 | onPressed: () {}, 89 | ), 90 | ); 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /lib/src/pages/demo/demo33/demo_AnimatedContainer.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/cupertino.dart'; 2 | import 'package:flutter/material.dart'; 3 | 4 | /// 创建人: Created by zhaolong 5 | /// 创建时间:Created by on 3/26/21. 6 | /// 7 | /// 可关注公众号:我的大前端生涯 获取最新技术分享 8 | /// 可关注网易云课堂:https://study.163.com/instructor/1021406098.htm 9 | /// 可关注博客:https://blog.csdn.net/zl18603543572 10 | /// 11 | /// 12 | /// 13 | /// 14 | main() { 15 | runApp(MaterialApp( 16 | //不显示 debug标签 17 | debugShowCheckedModeBanner: false, 18 | //显示的首页面 19 | home: DemoAnimatedContainer(), 20 | )); 21 | } 22 | 23 | ///代码清单 24 | class DemoAnimatedContainer extends StatefulWidget { 25 | @override 26 | _DemoAnimatedContainerState createState() => _DemoAnimatedContainerState(); 27 | } 28 | 29 | class _DemoAnimatedContainerState extends State { 30 | @override 31 | Widget build(BuildContext context) { 32 | return Scaffold( 33 | appBar: AppBar(title: Text("AnimatedContainer")), 34 | body: Center( 35 | child: AnimatedContainer( 36 | //动画速率 37 | curve: Curves.easeInBack, 38 | //动画执行结束的回调 39 | onEnd: () {}, 40 | //子Widget 对齐方式 41 | alignment: Alignment.center, 42 | width: 300, 43 | //高度 44 | height: 200, 45 | //背景颜色 46 | // color: Colors.deepPurple, 47 | //内边距 48 | padding: EdgeInsets.all(0), 49 | //复杂装饰样式 50 | decoration: BoxDecoration( 51 | //背景色 52 | color: Colors.red, 53 | //边框圆角 54 | borderRadius: BorderRadius.all(Radius.circular(20)), 55 | //边框 56 | border: Border.all(color: Colors.deepPurple, width: 1), 57 | //线性渐变 58 | gradient: LinearGradient( 59 | //开始位置 60 | begin: Alignment(0, 0), 61 | //结束位置 62 | end: Alignment(1, 0), 63 | //颜色组 64 | colors: [ 65 | Colors.blue, 66 | Colors.deepOrange, 67 | Colors.orange, 68 | ]), 69 | ), 70 | 71 | duration: Duration(seconds: 2), 72 | child: Text( 73 | "早起的年轻人", 74 | style: TextStyle(color: Colors.white), 75 | ), 76 | ), 77 | ), 78 | ); 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /lib/src/pages/demo/demo33/demo_AnimatedDefaultTextStyle.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/cupertino.dart'; 2 | import 'package:flutter/material.dart'; 3 | 4 | /// 创建人: Created by zhaolong 5 | /// 创建时间:Created by on 3/26/21. 6 | /// 7 | /// 可关注公众号:我的大前端生涯 获取最新技术分享 8 | /// 可关注网易云课堂:https://study.163.com/instructor/1021406098.htm 9 | /// 可关注博客:https://blog.csdn.net/zl18603543572 10 | /// 11 | /// 12 | /// 13 | /// 14 | main() { 15 | runApp(MaterialApp( 16 | //不显示 debug标签 17 | debugShowCheckedModeBanner: false, 18 | //显示的首页面 19 | home: DemoAnimatedDefaultTextStylePage(), 20 | )); 21 | } 22 | 23 | ///代码清单 24 | class DemoAnimatedDefaultTextStylePage extends StatefulWidget { 25 | @override 26 | _DemoAnimatedDefaultTextStylePageState createState() => 27 | _DemoAnimatedDefaultTextStylePageState(); 28 | } 29 | 30 | class _DemoAnimatedDefaultTextStylePageState 31 | extends State { 32 | bool _select = false; 33 | TextStyle _style = TextStyle(); 34 | 35 | @override 36 | Widget build(BuildContext context) { 37 | return Scaffold( 38 | appBar: AppBar(title: Text("这里是首页")), 39 | body: Center( 40 | child: AnimatedDefaultTextStyle( 41 | duration: Duration(seconds: 2), 42 | style: _style, 43 | child: Text( 44 | "早起的年轻人", 45 | ), 46 | ), 47 | ), 48 | floatingActionButton: FloatingActionButton( 49 | child: Icon(Icons.add), 50 | onPressed: () { 51 | if (!_select) { 52 | _style = TextStyle( 53 | fontSize: 16, 54 | color: Colors.orange, 55 | fontWeight: FontWeight.w600); 56 | } else { 57 | _style = TextStyle(fontSize: 22, color: Colors.green); 58 | } 59 | _select = !_select; 60 | setState(() {}); 61 | }, 62 | ), 63 | ); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /lib/src/pages/demo/demo33/demo_AnimatedOpacity.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/cupertino.dart'; 2 | import 'package:flutter/material.dart'; 3 | 4 | /// 创建人: Created by zhaolong 5 | /// 创建时间:Created by on 3/26/21. 6 | /// 7 | /// 可关注公众号:我的大前端生涯 获取最新技术分享 8 | /// 可关注网易云课堂:https://study.163.com/instructor/1021406098.htm 9 | /// 可关注博客:https://blog.csdn.net/zl18603543572 10 | /// 11 | /// 12 | /// 13 | /// 14 | main() { 15 | runApp(MaterialApp( 16 | //不显示 debug标签 17 | debugShowCheckedModeBanner: false, 18 | //显示的首页面 19 | home: DemoAnimatedOpacity(), 20 | )); 21 | } 22 | 23 | ///代码清单 24 | class DemoAnimatedOpacity extends StatefulWidget { 25 | @override 26 | _DemoAnimatedOpacityState createState() => _DemoAnimatedOpacityState(); 27 | } 28 | 29 | class _DemoAnimatedOpacityState extends State { 30 | double _opacity = 0.0; 31 | 32 | @override 33 | Widget build(BuildContext context) { 34 | return Scaffold( 35 | appBar: AppBar(title: Text("这里是首页")), 36 | body: Container( 37 | width: double.infinity, 38 | height: double.infinity, 39 | child: Column( 40 | mainAxisAlignment: MainAxisAlignment.center, 41 | children: [ 42 | AnimatedOpacity( 43 | //动画时间 44 | duration: Duration(seconds: 2), 45 | //透明度 46 | opacity: _opacity, 47 | //动画执行结束回调 48 | onEnd: () {}, 49 | //动画曲线 50 | curve: Curves.fastOutSlowIn, 51 | child: Container( 52 | padding: EdgeInsets.all(20), 53 | child: FlutterLogo( 54 | size: 100, 55 | ), 56 | color: Colors.grey, 57 | ), 58 | ), 59 | ], 60 | ), 61 | ), 62 | floatingActionButton: FloatingActionButton( 63 | onPressed: () { 64 | setState(() { 65 | _opacity = _opacity == 0.0 ? 1.0 : 0.0; 66 | }); 67 | }, 68 | child: Text("显示"), 69 | ), 70 | ); 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /lib/src/pages/demo/demo33/demo_AnimatedPaddind.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/cupertino.dart'; 2 | import 'package:flutter/material.dart'; 3 | 4 | /// 创建人: Created by zhaolong 5 | /// 创建时间:Created by on 3/26/21. 6 | /// 7 | /// 可关注公众号:我的大前端生涯 获取最新技术分享 8 | /// 可关注网易云课堂:https://study.163.com/instructor/1021406098.htm 9 | /// 可关注博客:https://blog.csdn.net/zl18603543572 10 | /// 11 | /// 12 | /// 13 | /// 14 | main() { 15 | runApp(MaterialApp( 16 | //不显示 debug标签 17 | debugShowCheckedModeBanner: false, 18 | //显示的首页面 19 | home: DemoAnimatedAnimatedPadding(), 20 | )); 21 | } 22 | 23 | ///代码清单 24 | class DemoAnimatedAnimatedPadding extends StatefulWidget { 25 | @override 26 | _DemoAnimatedAnimatedPaddingState createState() => 27 | _DemoAnimatedAnimatedPaddingState(); 28 | } 29 | 30 | class _DemoAnimatedAnimatedPaddingState 31 | extends State { 32 | @override 33 | Widget build(BuildContext context) { 34 | return Scaffold( 35 | appBar: AppBar(title: Text("AnimatedPadding")), 36 | body: Center( 37 | child: GestureDetector( 38 | child: AnimatedPadding( 39 | child: Text("早起的年轻人"), 40 | //动画执行完成回调 41 | onEnd: () {}, 42 | curve: Curves.decelerate, 43 | padding: EdgeInsets.only(left: 32, right: 22), 44 | duration: Duration(seconds: 2), 45 | ), 46 | onTap: () {}, 47 | ), 48 | ), 49 | ); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /lib/src/pages/demo/demo33/demo_AnimatedPhysicalModel.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/cupertino.dart'; 2 | import 'package:flutter/material.dart'; 3 | 4 | /// 创建人: Created by zhaolong 5 | /// 创建时间:Created by on 3/26/21. 6 | /// 7 | /// 可关注公众号:我的大前端生涯 获取最新技术分享 8 | /// 可关注网易云课堂:https://study.163.com/instructor/1021406098.htm 9 | /// 可关注博客:https://blog.csdn.net/zl18603543572 10 | /// 11 | /// 12 | /// 13 | /// 14 | main() { 15 | runApp(MaterialApp( 16 | //不显示 debug标签 17 | debugShowCheckedModeBanner: false, 18 | //显示的首页面 19 | home: DemoAnimatedPhysicalModel(), 20 | )); 21 | } 22 | 23 | ///代码清单 24 | class DemoAnimatedPhysicalModel extends StatefulWidget { 25 | @override 26 | _DemoAnimatedPhysicalModelState createState() => 27 | _DemoAnimatedPhysicalModelState(); 28 | } 29 | 30 | class _DemoAnimatedPhysicalModelState extends State { 31 | @override 32 | Widget build(BuildContext context) { 33 | return Scaffold( 34 | appBar: AppBar(title: Text("AnimatedPhysicalModel")), 35 | body: Center( 36 | child: AnimatedPhysicalModel( 37 | //阴影的圆角 38 | borderRadius: BorderRadius.all(Radius.circular(20)), 39 | //时间 40 | duration: Duration(seconds: 2), 41 | //阴影颜色 42 | shadowColor: Colors.deepPurple, 43 | //true 启动阴影颜色变化动画 44 | animateShadowColor: true, 45 | //背景 46 | color: Colors.green, 47 | //阴影高度 48 | elevation: 22.0, 49 | //阴影形状 50 | shape: BoxShape.rectangle, 51 | //动画执行完成 52 | onEnd: () {}, 53 | //动画速率 54 | curve: Curves.bounceInOut, 55 | child: Container( 56 | alignment: Alignment.center, 57 | width: 200, 58 | height: 200, 59 | color: Colors.blue, 60 | child: Text( 61 | "早起的年轻人", 62 | style: TextStyle(color: Colors.white), 63 | ), 64 | ), 65 | ), 66 | ), 67 | ); 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /lib/src/pages/demo/demo33/demo_AnimatedPositionedDirectional.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/cupertino.dart'; 2 | import 'package:flutter/material.dart'; 3 | 4 | /// 创建人: Created by zhaolong 5 | /// 创建时间:Created by on 3/26/21. 6 | /// 7 | /// 可关注公众号:我的大前端生涯 获取最新技术分享 8 | /// 可关注网易云课堂:https://study.163.com/instructor/1021406098.htm 9 | /// 可关注博客:https://blog.csdn.net/zl18603543572 10 | /// 11 | /// 12 | /// 13 | /// 14 | main() { 15 | runApp(MaterialApp( 16 | //不显示 debug标签 17 | debugShowCheckedModeBanner: false, 18 | //显示的首页面 19 | home: DemoAnimatedPositionedDirectionalPage(), 20 | )); 21 | } 22 | 23 | ///代码清单 24 | class DemoAnimatedPositionedDirectionalPage extends StatefulWidget { 25 | @override 26 | _DemoAnimatedPositionedDirectionalPageState createState() => 27 | _DemoAnimatedPositionedDirectionalPageState(); 28 | } 29 | 30 | class _DemoAnimatedPositionedDirectionalPageState 31 | extends State { 32 | @override 33 | Widget build(BuildContext context) { 34 | return Scaffold( 35 | appBar: AppBar(title: Text("这里是首页")), 36 | body: Container( 37 | width: double.infinity, 38 | height: double.infinity, 39 | child: Directionality( 40 | // TextDirection.ltr left to right 从左到右 41 | // TextDirection.rtl rtl right to left 42 | textDirection: TextDirection.ltr, 43 | child: Stack( 44 | children: [ 45 | AnimatedPositionedDirectional( 46 | top: 100, 47 | start: 300, 48 | width: 100, 49 | height: 200, 50 | duration: Duration(seconds: 2), 51 | //执行结束回调 52 | onEnd: () {}, 53 | //动画曲线 54 | curve: Curves.fastOutSlowIn, 55 | child: Container( 56 | color: Colors.blue, 57 | child: Text("早起的年轻人"), 58 | ), 59 | ), 60 | ], 61 | ), 62 | ), 63 | ), 64 | ); 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /lib/src/pages/demo/demo33/demo_Positioned.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/cupertino.dart'; 2 | import 'package:flutter/material.dart'; 3 | 4 | /// 创建人: Created by zhaolong 5 | /// 创建时间:Created by on 3/26/21. 6 | /// 7 | /// 可关注公众号:我的大前端生涯 获取最新技术分享 8 | /// 可关注网易云课堂:https://study.163.com/instructor/1021406098.htm 9 | /// 可关注博客:https://blog.csdn.net/zl18603543572 10 | /// 11 | /// 12 | /// 13 | /// 14 | main() { 15 | runApp(MaterialApp( 16 | //不显示 debug标签 17 | debugShowCheckedModeBanner: false, 18 | //显示的首页面 19 | home: DemoPositionedPage(), 20 | )); 21 | } 22 | 23 | ///代码清单 24 | class DemoPositionedPage extends StatefulWidget { 25 | @override 26 | _DemoPositionedPageState createState() => _DemoPositionedPageState(); 27 | } 28 | 29 | class _DemoPositionedPageState extends State { 30 | double _top = 100; 31 | @override 32 | Widget build(BuildContext context) { 33 | return Scaffold( 34 | appBar: AppBar(title: Text("这里是首页")), 35 | body: Container( 36 | width: double.infinity, 37 | height: double.infinity, 38 | child: Stack( 39 | alignment: Alignment.center, 40 | children: [ 41 | AnimatedPositioned( 42 | top: 400, 43 | left: 100, 44 | //动画时间 45 | duration: Duration(seconds: 2), 46 | //动画曲线 47 | curve: Curves.bounceIn, 48 | onEnd: () { 49 | print("动画执行完成"); 50 | }, 51 | child: Text( 52 | "早起的年轻人", 53 | style: TextStyle( 54 | fontWeight: FontWeight.w600, 55 | color: Colors.blueAccent, 56 | ), 57 | ), 58 | ) 59 | ], 60 | ), 61 | ), 62 | floatingActionButton: FloatingActionButton( 63 | child: Text("切换"), 64 | onPressed: () { 65 | setState(() { 66 | _top += 20; 67 | }); 68 | }, 69 | ), 70 | ); 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /lib/src/pages/demo/demo33/demo_PositionedTransition.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/cupertino.dart'; 2 | import 'package:flutter/material.dart'; 3 | 4 | /// 创建人: Created by zhaolong 5 | /// 创建时间:Created by on 3/26/21. 6 | /// 7 | /// 可关注公众号:我的大前端生涯 获取最新技术分享 8 | /// 可关注网易云课堂:https://study.163.com/instructor/1021406098.htm 9 | /// 可关注博客:https://blog.csdn.net/zl18603543572 10 | /// 11 | /// 12 | /// 13 | /// 14 | main() { 15 | runApp(MaterialApp( 16 | //不显示 debug标签 17 | debugShowCheckedModeBanner: false, 18 | //显示的首页面 19 | home: DemoPositionedTransition(), 20 | )); 21 | } 22 | 23 | ///代码清单 24 | class DemoPositionedTransition extends StatefulWidget { 25 | @override 26 | _DemoPositionedTransitionState createState() => 27 | _DemoPositionedTransitionState(); 28 | } 29 | 30 | class _DemoPositionedTransitionState extends State 31 | with SingleTickerProviderStateMixin { 32 | // 0.0 ~ 1.0 默认 33 | late AnimationController _animationController; 34 | late Animation rectAnimation; 35 | @override 36 | void initState() { 37 | super.initState(); 38 | // 0.0 ~ 1.0 默认 39 | _animationController = new AnimationController( 40 | vsync: this, duration: Duration(milliseconds: 1000)); 41 | rectAnimation = RelativeRectTween( 42 | begin: RelativeRect.fromLTRB(100, 100, 10, 10), 43 | end: RelativeRect.fromLTRB(10, 10, 100, 100), 44 | ).animate(_animationController); 45 | } 46 | 47 | @override 48 | Widget build(BuildContext context) { 49 | return Scaffold( 50 | appBar: AppBar(title: Text("PositionedTransition")), 51 | body: Center( 52 | child: Container( 53 | height: 400, 54 | width: 300, 55 | color: Colors.grey[200], 56 | child: Stack( 57 | alignment: Alignment.center, 58 | children: [ 59 | Container( 60 | color: Colors.blue, 61 | width: 100, 62 | height: 100, 63 | ), 64 | PositionedTransition( 65 | rect: rectAnimation, 66 | child: Container( 67 | color: Colors.orange, 68 | width: 66, 69 | height: 66, 70 | ), 71 | ), 72 | ], 73 | ), 74 | ), 75 | ), 76 | floatingActionButton: FloatingActionButton( 77 | child: Text("开始"), 78 | onPressed: () { 79 | if (_animationController.status == AnimationStatus.dismissed) { 80 | _animationController.forward(); 81 | } else if (_animationController.status == AnimationStatus.completed) { 82 | _animationController.reverse(); 83 | } 84 | }, 85 | ), 86 | ); 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /lib/src/pages/demo/demo33/demo_RotationTransition.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/cupertino.dart'; 2 | import 'package:flutter/material.dart'; 3 | 4 | /// 创建人: Created by zhaolong 5 | /// 创建时间:Created by on 3/26/21. 6 | /// 7 | /// 可关注公众号:我的大前端生涯 获取最新技术分享 8 | /// 可关注网易云课堂:https://study.163.com/instructor/1021406098.htm 9 | /// 可关注博客:https://blog.csdn.net/zl18603543572 10 | /// 11 | /// 12 | /// 13 | /// 14 | main() { 15 | runApp(MaterialApp( 16 | //不显示 debug标签 17 | debugShowCheckedModeBanner: false, 18 | //显示的首页面 19 | home: DemoRotationTransition(), 20 | )); 21 | } 22 | 23 | ///代码清单 24 | class DemoRotationTransition extends StatefulWidget { 25 | @override 26 | _DemoRotationTransitionState createState() => _DemoRotationTransitionState(); 27 | } 28 | 29 | class _DemoRotationTransitionState extends State 30 | with SingleTickerProviderStateMixin { 31 | // 0.0 ~ 1.0 默认 32 | late AnimationController _animationController; 33 | 34 | late Animation _animation; 35 | 36 | @override 37 | void initState() { 38 | super.initState(); 39 | // 0.0 ~ 1.0 默认 40 | _animationController = new AnimationController( 41 | vsync: this, 42 | duration: Duration(milliseconds: 4000), 43 | ); 44 | 45 | _animation = 46 | Tween(begin: 0.0, end: 0.5).animate(_animationController); 47 | } 48 | 49 | @override 50 | Widget build(BuildContext context) { 51 | return Scaffold( 52 | appBar: AppBar(title: Text("RotationTransition")), 53 | body: Center( 54 | //缩放动画 55 | child: RotationTransition( 56 | //旋转中心配制 57 | // Alignment.centerLeft 左居中 58 | alignment: Alignment.centerLeft, 59 | //0.0~1.0 旋转了 360度 60 | // rotated v * 2 * pi 61 | // 0.5 * 2 * pi = 180 度 62 | turns: _animation, 63 | child: Container( 64 | color: Colors.blue, 65 | height: 100, 66 | width: 200, 67 | ), 68 | ), 69 | ), 70 | floatingActionButton: FloatingActionButton( 71 | child: Text("开始"), 72 | onPressed: () { 73 | //动画未执行时状态 AnimationStatus.dismissed 74 | if (_animationController.status == AnimationStatus.dismissed) { 75 | //正向执行动画 76 | _animationController.forward(); 77 | } else if (_animationController.status == AnimationStatus.completed) { 78 | // AnimationStatus.completed 动画已正向执行完毕状态 79 | 80 | //反向执行动画 81 | _animationController.reverse(); 82 | } 83 | }, 84 | ), 85 | ); 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /lib/src/pages/demo/demo33/demo_ScaleTransition.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/cupertino.dart'; 2 | import 'package:flutter/material.dart'; 3 | 4 | /// 创建人: Created by zhaolong 5 | /// 创建时间:Created by on 3/26/21. 6 | /// 7 | /// 可关注公众号:我的大前端生涯 获取最新技术分享 8 | /// 可关注网易云课堂:https://study.163.com/instructor/1021406098.htm 9 | /// 可关注博客:https://blog.csdn.net/zl18603543572 10 | /// 11 | /// 12 | /// 13 | /// 14 | main() { 15 | runApp(MaterialApp( 16 | //不显示 debug标签 17 | debugShowCheckedModeBanner: false, 18 | //显示的首页面 19 | home: DemoScaleTransition(), 20 | )); 21 | } 22 | 23 | ///代码清单 24 | class DemoScaleTransition extends StatefulWidget { 25 | @override 26 | _DemoScaleTransitionState createState() => _DemoScaleTransitionState(); 27 | } 28 | 29 | class _DemoScaleTransitionState extends State 30 | with SingleTickerProviderStateMixin { 31 | late Animation scaleAnimation; 32 | 33 | // 0.0 ~ 1.0 默认 34 | late AnimationController _animationController; 35 | 36 | @override 37 | void initState() { 38 | super.initState(); 39 | // 0.0 ~ 1.0 默认 40 | _animationController = new AnimationController( 41 | vsync: this, duration: Duration(milliseconds: 1000)); 42 | 43 | scaleAnimation = new Tween(begin: 1.0, end: 0.2).animate( 44 | CurvedAnimation( 45 | parent: _animationController, 46 | curve: Curves.bounceInOut, 47 | ), 48 | ); 49 | } 50 | 51 | @override 52 | Widget build(BuildContext context) { 53 | return Scaffold( 54 | appBar: AppBar(title: Text("ScaleTransition")), 55 | body: Center( 56 | //缩放动画 57 | child: ScaleTransition( 58 | scale: scaleAnimation, 59 | child: Container( 60 | color: Colors.blue, 61 | height: 200, 62 | width: 200, 63 | ), 64 | ), 65 | ), 66 | floatingActionButton: FloatingActionButton( 67 | child: Text("开始"), 68 | onPressed: () { 69 | if (_animationController.status == AnimationStatus.dismissed) { 70 | _animationController.forward(); 71 | } else if (_animationController.status == AnimationStatus.completed) { 72 | _animationController.reverse(); 73 | } 74 | }, 75 | ), 76 | ); 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /lib/src/pages/demo/demo33/demo_SizeTransition.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/cupertino.dart'; 2 | import 'package:flutter/material.dart'; 3 | 4 | /// 创建人: Created by zhaolong 5 | /// 创建时间:Created by on 3/26/21. 6 | /// 7 | /// 可关注公众号:我的大前端生涯 获取最新技术分享 8 | /// 可关注网易云课堂:https://study.163.com/instructor/1021406098.htm 9 | /// 可关注博客:https://blog.csdn.net/zl18603543572 10 | /// 11 | /// 12 | /// 13 | /// 14 | main() { 15 | runApp(MaterialApp( 16 | //不显示 debug标签 17 | debugShowCheckedModeBanner: false, 18 | //显示的首页面 19 | home: DemoSizeTransition(), 20 | )); 21 | } 22 | 23 | ///代码清单 24 | class DemoSizeTransition extends StatefulWidget { 25 | @override 26 | _DemoSizeTransitionState createState() => _DemoSizeTransitionState(); 27 | } 28 | 29 | class _DemoSizeTransitionState extends State 30 | with SingleTickerProviderStateMixin { 31 | late AnimationController _animationController; 32 | 33 | @override 34 | void initState() { 35 | super.initState(); 36 | 37 | _animationController = 38 | new AnimationController(vsync: this, duration: Duration(seconds: 2)); 39 | } 40 | 41 | @override 42 | Widget build(BuildContext context) { 43 | return Scaffold( 44 | appBar: AppBar(title: Text("SizeTransition")), 45 | body: Center( 46 | child: SizeTransition( 47 | //偏移量 48 | axisAlignment: 1.0, 49 | //动画控制 50 | sizeFactor: _animationController, 51 | axis: Axis.vertical, 52 | child: buildContainer(), 53 | ), 54 | ), 55 | floatingActionButton: FloatingActionButton( 56 | child: Text("开始"), 57 | onPressed: () { 58 | _animationController.forward(from: 0); 59 | }, 60 | ), 61 | ); 62 | } 63 | 64 | Container buildContainer() { 65 | return Container( 66 | //子Widget 对齐方式 67 | alignment: Alignment.center, 68 | width: 300, 69 | //高度 70 | height: 200, 71 | //背景颜色 72 | color: Colors.blue, 73 | child: Text( 74 | "早起的年轻人", 75 | style: TextStyle(color: Colors.white), 76 | ), 77 | ); 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /lib/src/pages/demo/demo33/demo_SlideTransition.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/cupertino.dart'; 2 | import 'package:flutter/material.dart'; 3 | 4 | /// 创建人: Created by zhaolong 5 | /// 创建时间:Created by on 3/26/21. 6 | /// 7 | /// 可关注公众号:我的大前端生涯 获取最新技术分享 8 | /// 可关注网易云课堂:https://study.163.com/instructor/1021406098.htm 9 | /// 可关注博客:https://blog.csdn.net/zl18603543572 10 | /// 11 | /// 12 | /// 13 | /// 14 | main() { 15 | runApp(MaterialApp( 16 | //不显示 debug标签 17 | debugShowCheckedModeBanner: false, 18 | //显示的首页面 19 | home: DemoSlideTransition(), 20 | )); 21 | } 22 | 23 | ///代码清单 24 | class DemoSlideTransition extends StatefulWidget { 25 | @override 26 | _DemoSlideTransitionState createState() => _DemoSlideTransitionState(); 27 | } 28 | 29 | class _DemoSlideTransitionState extends State 30 | with SingleTickerProviderStateMixin { 31 | late Animation _animation; 32 | late AnimationController _animationController; 33 | 34 | @override 35 | void initState() { 36 | super.initState(); 37 | 38 | _animationController = AnimationController( 39 | vsync: this, 40 | duration: Duration(milliseconds: 900), 41 | ); 42 | _animation = Tween(begin: Offset(0, 0), end: Offset(0, 0.5)) 43 | .animate(_animationController); 44 | } 45 | 46 | @override 47 | Widget build(BuildContext context) { 48 | return Scaffold( 49 | appBar: AppBar(title: Text("SlideTransition")), 50 | body: Center( 51 | child: SlideTransition( 52 | position: _animation, 53 | child: Container( 54 | color: Colors.blue, 55 | height: 200, 56 | width: 200, 57 | ), 58 | ), 59 | ), 60 | floatingActionButton: FloatingActionButton( 61 | child: Text("开始"), 62 | onPressed: () { 63 | //动画状态 64 | AnimationStatus animationStatus = _animationController.status; 65 | //AnimationStatus.dismissed 未开始执行 66 | if (animationStatus == AnimationStatus.dismissed) { 67 | _animationController.forward(from: 0); 68 | } else if (animationStatus == AnimationStatus.forward) { 69 | //执行中 70 | } else if (animationStatus == AnimationStatus.completed) { 71 | //执行完成 正向执行 72 | 73 | //反向开始执行 74 | _animationController.reverse(); 75 | } else if (animationStatus == AnimationStatus.reverse) { 76 | //执行完成 逆向 77 | 78 | _animationController.forward(from: 0); 79 | } 80 | }, 81 | ), 82 | ); 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /lib/src/pages/demo/demo33/demo_SliverAnimatedOpacity.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/cupertino.dart'; 2 | import 'package:flutter/material.dart'; 3 | 4 | /// 创建人: Created by zhaolong 5 | /// 创建时间:Created by on 3/26/21. 6 | /// 7 | /// 可关注公众号:我的大前端生涯 获取最新技术分享 8 | /// 可关注网易云课堂:https://study.163.com/instructor/1021406098.htm 9 | /// 可关注博客:https://blog.csdn.net/zl18603543572 10 | /// 11 | /// 12 | /// 13 | /// 14 | main() { 15 | runApp(MaterialApp( 16 | //不显示 debug标签 17 | debugShowCheckedModeBanner: false, 18 | //显示的首页面 19 | home: DemoAnimatedOpacity(), 20 | )); 21 | } 22 | 23 | ///代码清单 24 | class DemoAnimatedOpacity extends StatefulWidget { 25 | @override 26 | _DemoAnimatedOpacityState createState() => _DemoAnimatedOpacityState(); 27 | } 28 | 29 | class _DemoAnimatedOpacityState extends State { 30 | @override 31 | Widget build(BuildContext context) { 32 | return Scaffold( 33 | appBar: AppBar(title: Text("这里是首页")), 34 | body: CustomScrollView( 35 | slivers: [ 36 | SliverAnimatedOpacity( 37 | //动画执行完毕 38 | onEnd: () {}, 39 | //动画曲线 40 | curve: Curves.decelerate, 41 | //透明度 42 | opacity: 1.0, 43 | //动画时间 44 | duration: Duration(seconds: 2), 45 | //子 Widet 46 | sliver: SliverFixedExtentList( 47 | delegate: SliverChildBuilderDelegate( 48 | (BuildContext context, int index) { 49 | return Container( 50 | color: index % 2 == 0 51 | ? Colors.deepOrange[200] 52 | : Colors.deepOrange[400], 53 | child: Text("早起的年轻人"), 54 | ); 55 | }), 56 | itemExtent: 100.0), 57 | ) 58 | ], 59 | ), 60 | ); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /lib/src/pages/demo/demo34/demo_TextField.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/cupertino.dart'; 2 | import 'package:flutter/material.dart'; 3 | 4 | /// 创建人: Created by zhaolong 5 | /// 创建时间:Created by on 3/26/21. 6 | /// 7 | /// 可关注公众号:我的大前端生涯 获取最新技术分享 8 | /// 可关注网易云课堂:https://study.163.com/instructor/1021406098.htm 9 | /// 可关注博客:https://blog.csdn.net/zl18603543572 10 | /// 11 | /// 12 | /// 13 | /// 14 | main() { 15 | runApp(MaterialApp( 16 | //不显示 debug标签 17 | debugShowCheckedModeBanner: false, 18 | //显示的首页面 19 | home: DemoTextFieldPage(), 20 | )); 21 | } 22 | 23 | ///代码清单 24 | class DemoTextFieldPage extends StatefulWidget { 25 | @override 26 | _DemoTextFieldPageState createState() => _DemoTextFieldPageState(); 27 | } 28 | 29 | class _DemoTextFieldPageState extends State { 30 | TextEditingController _textEditingController = new TextEditingController(); 31 | 32 | @override 33 | Widget build(BuildContext context) { 34 | return Scaffold( 35 | appBar: AppBar(title: Text("这里是首页")), 36 | body: Container( 37 | child: Column( 38 | children: [ 39 | TextField( 40 | controller: _textEditingController, 41 | ), 42 | SizedBox( 43 | height: 33, 44 | ), 45 | ElevatedButton(onPressed: () {}, child: Text("动态设置")) 46 | ], 47 | ), 48 | ), 49 | ); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /lib/src/pages/demo/demo35/demo_TransformMatrix4Page.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/cupertino.dart'; 2 | import 'package:flutter/material.dart'; 3 | 4 | /// 创建人: Created by zhaolong 5 | /// 创建时间:Created by on 3/26/21. 6 | /// 7 | /// 可关注公众号:我的大前端生涯 获取最新技术分享 8 | /// 可关注网易云课堂:https://study.163.com/instructor/1021406098.htm 9 | /// 可关注博客:https://blog.csdn.net/zl18603543572 10 | /// 11 | /// 12 | /// 13 | /// 14 | /// 15 | /// 16 | /// 17 | /// 18 | /// 19 | /// 20 | /// 21 | /// 22 | main() { 23 | runApp(MaterialApp( 24 | //不显示 debug标签 25 | debugShowCheckedModeBanner: false, 26 | //显示的首页面 27 | home: DemoTransformImagePage(), 28 | )); 29 | } 30 | 31 | class DemoTransformImagePage extends StatefulWidget { 32 | @override 33 | _MyHomePageState createState() => _MyHomePageState(); 34 | } 35 | 36 | class _MyHomePageState extends State { 37 | 38 | double x = 0; 39 | double y = 0; 40 | double z = 0; 41 | @override 42 | Widget build(BuildContext context) { 43 | return Scaffold( 44 | appBar: AppBar(title: Text("Transform")), 45 | body: Center( 46 | child: Transform( 47 | transform: Matrix4( 48 | 1,0,0,0, 49 | 0,1,0,0, 50 | 0,0,1,0, 51 | 0,0,0,1, 52 | ) 53 | ..rotateZ(z) 54 | ..rotateX(x) 55 | ..rotateY(y) 56 | ..setEntry(3, 0, 0.0) 57 | ..setEntry(3, 1, -0.006), 58 | alignment: FractionalOffset.center, 59 | child: GestureDetector( 60 | onPanUpdate: (DragUpdateDetails details){ 61 | setState(() { 62 | y = y - details.delta.dx / 100; 63 | x = x + details.delta.dy / 100; 64 | }); 65 | }, 66 | child: Container( 67 | color: Colors.red, 68 | height: 200.0, 69 | width: 200.0, 70 | ), 71 | ), 72 | ), 73 | ), 74 | ); 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /lib/src/pages/demo/demo35/demo_TransformPage.dart: -------------------------------------------------------------------------------- 1 | import 'dart:math'; 2 | 3 | import 'package:flutter/cupertino.dart'; 4 | import 'package:flutter/material.dart'; 5 | 6 | /// 创建人: Created by zhaolong 7 | /// 创建时间:Created by on 3/26/21. 8 | /// 9 | /// 可关注公众号:我的大前端生涯 获取最新技术分享 10 | /// 可关注网易云课堂:https://study.163.com/instructor/1021406098.htm 11 | /// 可关注博客:https://blog.csdn.net/zl18603543572 12 | /// 13 | /// 14 | /// 15 | /// 16 | /// 17 | /// 18 | /// 19 | /// 20 | /// 21 | /// 22 | /// 23 | /// 24 | main() { 25 | runApp(MaterialApp( 26 | //不显示 debug标签 27 | debugShowCheckedModeBanner: false, 28 | //显示的首页面 29 | home: DemoTransformPage(), 30 | )); 31 | } 32 | 33 | ///代码清单 34 | class DemoTransformPage extends StatefulWidget { 35 | @override 36 | _DemoTransformPageState createState() => _DemoTransformPageState(); 37 | } 38 | 39 | class _DemoTransformPageState extends State { 40 | @override 41 | Widget build(BuildContext context) { 42 | return Scaffold( 43 | appBar: AppBar(title: Text("Transform")), 44 | body: Container( 45 | decoration: BoxDecoration( 46 | color: Colors.grey[200], 47 | border: Border.all(color: Colors.blue), 48 | ), 49 | child: buildScaleTransform(), 50 | ), 51 | ); 52 | } 53 | 54 | ///缩放 55 | Widget buildScaleTransform() { 56 | return Transform.scale( 57 | //相对平移量 58 | origin: Offset(10, 0), 59 | //缩放中心 60 | alignment: Alignment(-1, 0), 61 | //缩放的大小 62 | scale: 0.5, 63 | child: buildImage(), 64 | ); 65 | } 66 | 67 | ///平移 68 | Widget buildTransTransform() { 69 | return Transform.translate( 70 | //平移的距离 71 | offset: Offset(10, 100), 72 | child: buildImage(), 73 | ); 74 | } 75 | 76 | ///旋转 77 | Widget buildRotateTransform() { 78 | return Transform.rotate( 79 | //旋转中心 80 | // alignment: Alignment.bottomRight, 81 | //相对于组件中心的一个偏移 82 | origin: Offset(-10, -10), 83 | //顺时针 弧度 84 | angle: pi, 85 | //旋转的组件 86 | child: buildImage(), 87 | ); 88 | } 89 | 90 | Widget buildImage() { 91 | return Image.asset( 92 | "assets/images/banner1.png", 93 | height: 150, 94 | ); 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /lib/src/pages/demo/demo36/demo_ColorTweenPage.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/cupertino.dart'; 2 | import 'package:flutter/material.dart'; 3 | 4 | /// 创建人: Created by zhaolong 5 | /// 创建时间:Created by on 3/26/21. 6 | /// 7 | /// 可关注公众号:我的大前端生涯 获取最新技术分享 8 | /// 可关注网易云课堂:https://study.163.com/instructor/1021406098.htm 9 | /// 可关注博客:https://blog.csdn.net/zl18603543572 10 | /// 11 | /// 12 | /// 13 | /// 14 | /// 15 | /// 16 | /// 17 | /// 18 | /// 19 | /// 20 | /// 21 | /// 22 | main() { 23 | runApp(MaterialApp( 24 | //不显示 debug标签 25 | debugShowCheckedModeBanner: false, 26 | //显示的首页面 27 | home: DemoColorTweenPage(), 28 | )); 29 | } 30 | 31 | class DemoColorTweenPage extends StatefulWidget { 32 | @override 33 | _MyHomePageState createState() => _MyHomePageState(); 34 | } 35 | 36 | class _MyHomePageState extends State 37 | with SingleTickerProviderStateMixin { 38 | late AnimationController _animationController; 39 | late Animation _animation; 40 | 41 | @override 42 | void initState() { 43 | // TODO: implement initState 44 | super.initState(); 45 | 46 | //创建动画控制器 47 | _animationController = new AnimationController( 48 | vsync: this, 49 | duration: Duration(milliseconds: 1000), 50 | ); 51 | //添加动画执行刷新监听 52 | _animationController.addListener(() { 53 | setState(() {}); 54 | }); 55 | //添加动画状态监听 56 | _animationController.addStatusListener((status) { 57 | //获取动画执行状态 58 | AnimationStatus status = _animationController.status; 59 | 60 | //动画正向执行完成状态 61 | if (status == AnimationStatus.completed) { 62 | //反向开启动画 63 | _animationController.reverse(); 64 | } else if (status == AnimationStatus.dismissed) { 65 | //动画初始未执行或者是动画反向执行完成 66 | 67 | //正向开始执行动画 68 | _animationController.forward(); 69 | } 70 | }); 71 | //颜色动画变化 72 | _animation = ColorTween(begin: Colors.blue, end: Colors.red) 73 | .animate(_animationController); 74 | 75 | //添加到事件队列 76 | Future.delayed(Duration.zero, () { 77 | _animationController.forward(); 78 | }); 79 | } 80 | 81 | @override 82 | Widget build(BuildContext context) { 83 | return Scaffold( 84 | appBar: AppBar(title: Text("Tween")), 85 | body: Center( 86 | child: Container( 87 | width: 200, 88 | height: 200, 89 | color: _animation.value, 90 | ), 91 | ), 92 | ); 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /lib/src/pages/demo/demo37/AnimationWidget.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/cupertino.dart'; 2 | import 'package:flutter/material.dart'; 3 | 4 | /// 创建人: Created by zhaolong 5 | /// 创建时间:Created by on 5/27/21. 6 | /// 7 | 8 | /// [child] ListView 子Item显示的布局 9 | /// [index] ListView 子Itme位置 10 | /// AnimationWidget buildAnimationWidget(Widget child,int index) { 11 | // return AnimationWidget( 12 | // duration: 400 + index % 3 * 100, 13 | // child: child, 14 | // ); 15 | // } 16 | 17 | ///代码清单 18 | ///向上平移微动画 可应用于 ListView 19 | class AnimationWidget extends StatefulWidget { 20 | final Widget child; 21 | final int duration; 22 | 23 | const AnimationWidget({ 24 | Key? key, 25 | required this.child, 26 | this.duration = 200, 27 | }) : super(key: key); 28 | 29 | @override 30 | _AnimationWidgetState createState() => _AnimationWidgetState(); 31 | } 32 | 33 | class _AnimationWidgetState extends State 34 | with SingleTickerProviderStateMixin { 35 | //动画控制器 36 | late AnimationController _controller; 37 | 38 | //AnimationController是一个特殊的Animation对象,在屏幕刷新的每一帧,就会生成一个新的值, 39 | // 默认情况下,AnimationController在给定的时间段内会线性的生成从0.0到1.0的数字 40 | //用来控制动画的开始与结束以及设置动画的监听 41 | //vsync参数,存在vsync时会防止屏幕外动画(动画的UI不在当前屏幕时)消耗不必要的资源 42 | //duration 动画的时长,这里设置的 seconds: 2 为2秒,当然也可以设置毫秒 milliseconds:2000. 43 | late Animation _animation; 44 | 45 | @override 46 | void initState() { 47 | super.initState(); 48 | _controller = AnimationController( 49 | duration: Duration(milliseconds: widget.duration), vsync: this); 50 | //begin: Offset.zero, end: Offset(1, 0) 以左下角为参考点,相对于左下角坐标 x轴方向向右 平移执行动画的view 的1倍 宽度,y轴方向不动,也就是水平向右平移 51 | //begin: Offset.zero, end: Offset(1, 1) 以左下角为参考点,相对于左下角坐标 x轴方向向右 平移执行动画的view 的1倍 宽度,y轴方向 向下 平衡执行动画view 的1倍的高度,也就是向右下角平移了 52 | _animation = Tween( 53 | begin: Offset(0, 0.2), 54 | end: Offset(0, 0), 55 | ).animate(_controller); 56 | Future.delayed(Duration.zero, () { 57 | //开始执行动画 58 | _controller.forward(); 59 | }); 60 | } 61 | 62 | @override 63 | Widget build(BuildContext context) { 64 | return SlideTransition( 65 | position: _animation, 66 | child: widget.child, 67 | ); 68 | } 69 | 70 | @override 71 | void dispose() { 72 | _controller.dispose(); 73 | super.dispose(); 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /lib/src/pages/demo/demo38/demo_demo_AnimatedSwitcher.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/cupertino.dart'; 2 | import 'package:flutter/material.dart'; 3 | import 'package:flutter_svg/svg.dart'; 4 | 5 | /// 创建人: Created by zhaolong 6 | /// 创建时间:Created by on 3/26/21. 7 | /// 8 | /// 可关注公众号:我的大前端生涯 获取最新技术分享 9 | /// 可关注网易云课堂:https://study.163.com/instructor/1021406098.htm 10 | /// 可关注博客:https://blog.csdn.net/zl18603543572 11 | /// 12 | /// 13 | /// 14 | /// 15 | main() { 16 | runApp(MaterialApp( 17 | //不显示 debug标签 18 | debugShowCheckedModeBanner: false, 19 | //显示的首页面 20 | home: DemoAnimatedSwitcherLockPage(), 21 | )); 22 | } 23 | 24 | ///代码清单 25 | class DemoAnimatedSwitcherLockPage extends StatefulWidget { 26 | @override 27 | _DemoAnimatedSwitcherLockPageState createState() => 28 | _DemoAnimatedSwitcherLockPageState(); 29 | } 30 | 31 | class _DemoAnimatedSwitcherLockPageState 32 | extends State { 33 | bool _isLock = false; 34 | 35 | @override 36 | Widget build(BuildContext context) { 37 | 38 | ScaffoldMessenger.of(context).showSnackBar(const SnackBar( 39 | content: Text('Error'), 40 | backgroundColor: Colors.black54, 41 | )); 42 | 43 | 44 | return Scaffold( 45 | appBar: AppBar( 46 | title: Text("测试"), 47 | ), 48 | body: Center( 49 | child: DoorLock( 50 | press: () { 51 | setState(() { 52 | _isLock = !_isLock; 53 | }); 54 | }, 55 | isLock: _isLock, 56 | ), 57 | ), 58 | ); 59 | } 60 | } 61 | 62 | class DoorLock extends StatelessWidget { 63 | const DoorLock({ 64 | Key? key, 65 | required this.press, 66 | required this.isLock, 67 | }) : super(key: key); 68 | 69 | final VoidCallback press; 70 | final bool isLock; 71 | 72 | @override 73 | Widget build(BuildContext context) { 74 | return GestureDetector( 75 | onTap: press, 76 | child: AnimatedSwitcher( 77 | duration: Duration(milliseconds: 500), 78 | transitionBuilder: (Widget child, Animation animation) { 79 | return ScaleTransition( 80 | scale: animation, 81 | child: FadeTransition(opacity: animation, child: child), 82 | ); 83 | }, 84 | child: isLock 85 | ? SvgPicture.asset( 86 | "assets/svg/door_lock.svg", 87 | key: ValueKey("lock"), 88 | ) 89 | : SvgPicture.asset( 90 | "assets/svg/door_unlock.svg", 91 | key: ValueKey("unlock"), 92 | ), 93 | ), 94 | ); 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /lib/src/pages/demo/demo38/demo_demo_TweenAnimatedBuilder.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/cupertino.dart'; 2 | import 'package:flutter/material.dart'; 3 | import 'package:flutter_svg/svg.dart'; 4 | 5 | /// 创建人: Created by zhaolong 6 | /// 创建时间:Created by on 3/26/21. 7 | /// 8 | /// 可关注公众号:我的大前端生涯 获取最新技术分享 9 | /// 可关注网易云课堂:https://study.163.com/instructor/1021406098.htm 10 | /// 可关注博客:https://blog.csdn.net/zl18603543572 11 | /// 12 | /// 13 | /// 14 | /// 15 | main() { 16 | runApp(MaterialApp( 17 | //不显示 debug标签 18 | debugShowCheckedModeBanner: false, 19 | //显示的首页面 20 | home: DemoAnimatedTweenPage(), 21 | )); 22 | } 23 | 24 | ///代码清单 25 | class DemoAnimatedTweenPage extends StatefulWidget { 26 | @override 27 | _DemoAnimatedTweenPageState createState() => _DemoAnimatedTweenPageState(); 28 | } 29 | 30 | class _DemoAnimatedTweenPageState extends State { 31 | bool _isLock = false; 32 | 33 | @override 34 | Widget build(BuildContext context) { 35 | return Scaffold( 36 | body: Center( 37 | child: ElevatedButton( 38 | onPressed: () { 39 | // ignore: unnecessary_new 40 | Navigator.of(context).push(new MaterialPageRoute(builder: (_) { 41 | return DoorLock(); 42 | })); 43 | }, 44 | child: Text("打开新页面"), 45 | ), 46 | ), 47 | ); 48 | } 49 | } 50 | 51 | class DoorLock extends StatelessWidget { 52 | @override 53 | Widget build(BuildContext context) { 54 | return Center( 55 | child: TweenAnimationBuilder( 56 | duration: const Duration(milliseconds: 2000), 57 | tween: Tween(begin: 0, end: 1.0), 58 | builder: (BuildContext context, double value, Widget? child) { 59 | return Opacity( 60 | opacity: value, 61 | child: Padding( 62 | padding: EdgeInsets.only(top: 40 * value), 63 | child: child, 64 | ), 65 | ); 66 | }, 67 | child: Image.asset( 68 | "assets/images/sp02.png", 69 | width: 200, 70 | height: 100, 71 | fit: BoxFit.fitWidth, 72 | ), 73 | ), 74 | ); 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /lib/src/pages/demo/demo38/image_show_page.dart: -------------------------------------------------------------------------------- 1 | // Copyright 2020, the Flutter project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:flutter/material.dart'; 6 | import 'package:flutter_drag_scale_widget/flutter_drag_scale_widget.dart'; 7 | 8 | void main() { 9 | runApp( 10 | MaterialApp( 11 | home: TestPage(), 12 | debugShowCheckedModeBanner: false, 13 | ), 14 | ); 15 | } 16 | 17 | class TestPage extends StatelessWidget { 18 | @override 19 | Widget build(BuildContext context) { 20 | return Scaffold( 21 | body: Center( 22 | child: buildRow(), 23 | ), 24 | ); 25 | } 26 | 27 | final List _imageList = [ 28 | "assets/images/banner1.png", 29 | "assets/images/banner2.png", 30 | "assets/images/banner3.png" 31 | ]; 32 | 33 | Widget buildRow() { 34 | return ImageShowPageView( 35 | //图片数据 36 | imageList: _imageList, 37 | //图片的类型 38 | imageShowType: ImageShowType.ASSET, 39 | //图片的填充方式 40 | boxFit: BoxFit.contain, 41 | onPageChanged: (int index) { 42 | //滑动回调 43 | }, 44 | ); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /lib/src/pages/demo/demo38/layout_page.dart: -------------------------------------------------------------------------------- 1 | // Copyright 2020, the Flutter project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:flutter/material.dart'; 6 | import 'package:flutter_drag_scale_widget/flutter_drag_scale_widget.dart'; 7 | 8 | void main() { 9 | runApp( 10 | MaterialApp( 11 | home: LayoutBuilderPage(), 12 | debugShowCheckedModeBanner: false, 13 | ), 14 | ); 15 | } 16 | 17 | class LayoutBuilderPage extends StatelessWidget { 18 | @override 19 | Widget build(BuildContext context) { 20 | return Scaffold( 21 | body: Center( 22 | child: LayoutBuilder( 23 | builder: (BuildContext context, BoxConstraints constraints) { 24 | double maxWidth = constraints.maxWidth; 25 | double minWidth = constraints.minWidth; 26 | 27 | double maxHeight = constraints.maxHeight; 28 | double minHeight = constraints.minHeight; 29 | if (maxWidth > 400) { 30 | return buildRow(); 31 | } 32 | return buildColumn(); 33 | }, 34 | ), 35 | ), 36 | ); 37 | } 38 | 39 | Widget buildRow() { 40 | return Row( 41 | mainAxisAlignment: MainAxisAlignment.center, 42 | children: [ 43 | ElevatedButton(onPressed: () {}, child: Text("右侧按钮")), 44 | SizedBox( 45 | width: 60, 46 | ), 47 | ElevatedButton(onPressed: () {}, child: Text("左侧按钮")), 48 | ], 49 | ); 50 | } 51 | 52 | Widget buildColumn() { 53 | return Column( 54 | mainAxisAlignment: MainAxisAlignment.center, 55 | children: [ 56 | ElevatedButton(onPressed: () {}, child: Text("右侧按钮")), 57 | SizedBox( 58 | height: 60, 59 | ), 60 | ElevatedButton(onPressed: () {}, child: Text("左侧按钮")), 61 | ], 62 | ); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /lib/src/pages/demo/demo38/widget_masker.dart: -------------------------------------------------------------------------------- 1 | // Copyright 2020, the Flutter project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:flutter/material.dart'; 6 | 7 | void main() { 8 | runApp( 9 | MaterialApp( 10 | home: TestPage(), 11 | debugShowCheckedModeBanner: false, 12 | ), 13 | ); 14 | } 15 | 16 | class TestPage extends StatelessWidget { 17 | @override 18 | Widget build(BuildContext context) { 19 | return Scaffold( 20 | body: Center( 21 | child: buildRow(), 22 | ), 23 | ); 24 | } 25 | 26 | Row buildRow() { 27 | return Row( 28 | mainAxisAlignment: MainAxisAlignment.center, 29 | children: [ 30 | Image.asset("assets/images/test_icon.png", width: 100), 31 | const SizedBox(width: 55), 32 | ShaderMask( 33 | shaderCallback: (Rect bounds) { 34 | return const LinearGradient( 35 | colors: [Colors.grey, Colors.black], 36 | ).createShader(bounds); 37 | }, 38 | child: Image.asset("assets/images/test_icon.png", width: 100)), 39 | ], 40 | ); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /lib/src/pages/demo/demo39/demo_Container.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/cupertino.dart'; 2 | import 'package:flutter/material.dart'; 3 | import 'package:flutter_svg/svg.dart'; 4 | 5 | import 'demo_Container2.dart'; 6 | import 'demo_Container3.dart'; 7 | 8 | /// 创建人: Created by zhaolong 9 | /// 创建时间:Created by on 3/26/21. 10 | /// 11 | /// 可关注公众号:我的大前端生涯 获取最新技术分享 12 | /// 可关注网易云课堂:https://study.163.com/instructor/1021406098.htm 13 | /// 可关注博客:https://blog.csdn.net/zl18603543572 14 | /// 15 | /// 16 | /// 17 | /// 18 | main() { 19 | runApp(MaterialApp( 20 | //不显示 debug标签 21 | debugShowCheckedModeBanner: false, 22 | //显示的首页面 23 | home: DemoViewPaddingPage(), 24 | )); 25 | } 26 | 27 | ///代码清单 28 | class DemoAnimatedSwitcherLockPage extends StatefulWidget { 29 | @override 30 | _DemoAnimatedSwitcherLockPageState createState() => 31 | _DemoAnimatedSwitcherLockPageState(); 32 | } 33 | 34 | class _DemoAnimatedSwitcherLockPageState 35 | extends State { 36 | bool _isLock = false; 37 | 38 | @override 39 | Widget build(BuildContext context) { 40 | 41 | 42 | return Scaffold( 43 | body: Center( 44 | child: buildText(), 45 | ), 46 | ); 47 | } 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | Widget buildText() { 60 | return Container( 61 | //内边距 62 | padding: const EdgeInsets.only(left: 12, right: 12, top: 8, bottom: 8), 63 | //边框背景装饰 64 | decoration: BoxDecoration( 65 | //背景颜色 66 | color: Colors.grey, 67 | //边框 68 | border: Border.all(color: Colors.red,width: 1.0), 69 | //边框圆角 70 | borderRadius: BorderRadius.all(Radius.circular(22))), 71 | child: const Text("早起的年轻人"), 72 | ); 73 | } 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | } 87 | -------------------------------------------------------------------------------- /lib/src/pages/demo/demo39/demo_Container2.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/cupertino.dart'; 2 | import 'package:flutter/material.dart'; 3 | import 'package:flutter_svg/svg.dart'; 4 | 5 | ///代码清单 6 | class DemoStatefulBuilderPage extends StatelessWidget { 7 | int _count = 0; 8 | 9 | @override 10 | Widget build(BuildContext context) { 11 | return Scaffold( 12 | //状态构建器 13 | body: buildStatefulBuilder(), 14 | ); 15 | } 16 | 17 | StatefulBuilder buildStatefulBuilder() { 18 | return StatefulBuilder( 19 | //构建状态改变的Widget 20 | builder: (BuildContext context, void Function(void Function()) setState) { 21 | //居中 22 | return Center( 23 | //手势识别 24 | child: GestureDetector( 25 | child: Text("早起的年轻人 $_count"), 26 | //单击事件 27 | onTap: () { 28 | //刷新当前 StatefulBuilder 中的状态 29 | setState(() { 30 | _count++; 31 | }); 32 | }, 33 | ), 34 | ); 35 | }, 36 | ); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /lib/src/pages/demo/demo39/demo_Container3.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/cupertino.dart'; 2 | import 'package:flutter/material.dart'; 3 | import 'package:flutter_svg/svg.dart'; 4 | 5 | ///代码清单 6 | class DemoViewPaddingPage extends StatefulWidget { 7 | @override 8 | State createState() { 9 | return _DemoViewPaddingState(); 10 | } 11 | } 12 | 13 | class _DemoViewPaddingState extends State { 14 | @override 15 | Widget build(BuildContext context) { 16 | return Scaffold( 17 | resizeToAvoidBottomInset: false, 18 | //状态构建器 19 | body: SizedBox( 20 | child: LayoutBuilder( 21 | builder: (BuildContext context, BoxConstraints constraints) { 22 | MediaQueryData queryData = MediaQuery.of(context); 23 | //底部的遮挡部分 24 | EdgeInsets padding = queryData.padding; 25 | //顶部的遮挡部分 26 | EdgeInsets viewPadding = queryData.viewPadding; 27 | //键盘的高度 28 | EdgeInsets viewInsets = queryData.viewInsets; 29 | 30 | return Stack( 31 | alignment: Alignment.center, 32 | children: [ 33 | Positioned( 34 | top: 100, 35 | child: Column( 36 | mainAxisSize: MainAxisSize.min, 37 | children: [ 38 | Text(" padding padding ${padding.bottom}"), 39 | Text(" viewPadding padding ${viewPadding.bottom}"), 40 | Text(" viewInsets padding ${viewInsets.bottom}"), 41 | ], 42 | ), 43 | ), 44 | Positioned( 45 | bottom: padding.bottom+viewInsets.bottom, 46 | left: 20, 47 | right: 20, 48 | child: Container( 49 | color: Colors.grey, 50 | child: const TextField( 51 | decoration: InputDecoration(hintText: "请输入"), 52 | ), 53 | ), 54 | ), 55 | ], 56 | ); 57 | }, 58 | ), 59 | width: double.infinity, 60 | height: double.infinity, 61 | ), 62 | ); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /lib/src/pages/demo/demo4/FlowFliterWidget.dart: -------------------------------------------------------------------------------- 1 | import 'dart:ui'; 2 | 3 | import 'package:flutter/cupertino.dart'; 4 | import 'package:flutter/material.dart'; 5 | 6 | import 'FlowItemWidget.dart'; 7 | 8 | /// 创建人: Created by zhaolong 9 | /// 创建时间:Created by on 2021/2/13. 10 | /// 11 | /// 可关注公众号:我的大前端生涯 获取最新技术分享 12 | /// 可关注网易云课堂:https://study.163.com/instructor/1021406098.htm 13 | /// 可关注博客:https://blog.csdn.net/zl18603543572 14 | /// 15 | /// 代码清单 16 | ///代码清单 17 | class FlowFliterWidget extends StatefulWidget { 18 | final double flag; 19 | 20 | const FlowFliterWidget({Key? key, this.flag = 0.0}) : super(key: key); 21 | 22 | @override 23 | _FlowFliterWidgetState createState() => _FlowFliterWidgetState(); 24 | } 25 | 26 | class _FlowFliterWidgetState extends State { 27 | @override 28 | Widget build(BuildContext context) { 29 | return Stack( 30 | children: [ 31 | Positioned.fill( 32 | child: FlowItemWidget(), 33 | ), 34 | Positioned.fill( 35 | child: BackdropFilter( 36 | filter: ImageFilter.blur(sigmaY: 0.4, sigmaX: 0.4), 37 | child: Container( 38 | color: Colors.grey.withOpacity(widget.flag), 39 | ), 40 | ), 41 | ), 42 | ], 43 | ); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /lib/src/pages/demo/demo8/animation_1_expand_card.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | main() { 4 | runApp( 5 | MaterialApp( 6 | home: ExpandCardPage(), 7 | ), 8 | ); 9 | } 10 | 11 | class ExpandCardPage extends StatefulWidget { 12 | @override 13 | State createState() { 14 | return _ExpandCardPageState(); 15 | } 16 | } 17 | 18 | class _ExpandCardPageState extends State { 19 | 20 | @override 21 | Widget build(BuildContext context) { 22 | return Scaffold( 23 | backgroundColor: Colors.grey[200], 24 | appBar: AppBar( 25 | title: Text("测试Demo"), 26 | ), 27 | body: Center( 28 | child: buildBody(), 29 | ), 30 | ); 31 | } 32 | 33 | 34 | //选中标识 35 | bool _isSelect = false; 36 | //根据不同的选中标识来获取不同的大小 37 | double get size => _isSelect ? 120 : 220; 38 | 39 | Widget buildBody() { 40 | return GestureDetector( 41 | onTap: () { 42 | setState(() { 43 | _isSelect = !_isSelect; 44 | }); 45 | }, 46 | //卡片 47 | child: Card( 48 | //内边距 49 | child: Padding( 50 | padding: EdgeInsets.all(20), 51 | //动画容器 52 | child: AnimatedContainer( 53 | //动画时间 54 | duration: Duration(milliseconds: 1200), 55 | width: size, 56 | height: size, 57 | curve: Curves.ease, 58 | child: buildAnimateItem(), 59 | ), 60 | ), 61 | ), 62 | ); 63 | } 64 | 65 | buildAnimateItem() { 66 | return AnimatedCrossFade( 67 | //第一个Widget 68 | firstChild: Image.asset("assets/images/banner1.png"), 69 | //第二个Widget 70 | secondChild: Image.asset("assets/images/banner2.png",fit: BoxFit.fill,), 71 | //显示第几个Widget 72 | crossFadeState: 73 | _isSelect ? CrossFadeState.showSecond : CrossFadeState.showFirst, 74 | //两个Widget切换的时间 75 | duration: Duration(milliseconds: 1000), 76 | //定义两个Widget的排版方式 77 | layoutBuilder: (Widget topChild, Key topChildKey, Widget bottomChild, 78 | Key bottomChildKey) { 79 | return Stack( 80 | children: [ 81 | //第二个 底层 82 | Positioned.fill(child: bottomChild, key: bottomChildKey), 83 | //第一个 顶层 84 | Positioned.fill(child: topChild, key: topChildKey), 85 | ], 86 | ); 87 | }, 88 | ); 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /lib/src/pages/demo/demo_pie.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/cupertino.dart'; 2 | import 'package:flutter/material.dart'; 3 | import 'package:flutter_echart/flutter_echart.dart'; 4 | 5 | /// 创建人: Created by zhaolong 6 | /// 创建时间:Created by on 2021/1/11. 7 | /// 8 | /// 可关注公众号:我的大前端生涯 获取最新技术分享 9 | /// 可关注网易云课堂:https://study.163.com/instructor/1021406098.htm 10 | /// 可关注博客:https://blog.csdn.net/zl18603543572 11 | /// 12 | /// 代码清单 13 | ///代码清单 14 | /// 15 | main() { 16 | runApp(MaterialApp( 17 | home: DemoPiePage(), 18 | )); 19 | } 20 | 21 | class DemoPiePage extends StatefulWidget { 22 | @override 23 | _DemoPiePageState createState() => _DemoPiePageState(); 24 | } 25 | 26 | class _DemoPiePageState extends State { 27 | List _dataList = [ 28 | EChartPieBean(title: "生活费", number: 29, color: Colors.lightBlueAccent), 29 | EChartPieBean(title: "游玩费", number: 20, color: Colors.deepOrangeAccent), 30 | // EChartPieBean(title: "交通费", number: 400, color: Colors.green), 31 | // EChartPieBean(title: "贷款费", number: 300, color: Colors.amber), 32 | // EChartPieBean(title: "电话费", number: 200, color: Colors.orange), 33 | ]; 34 | 35 | @override 36 | Widget build(BuildContext context) { 37 | return Scaffold( 38 | appBar: AppBar( 39 | title: Text(""), 40 | ), 41 | backgroundColor: Colors.white, 42 | 43 | ///填充布局 44 | body: Center(child: Container(height: 200, child: buildPieChatWidget())), 45 | ); 46 | } 47 | 48 | PieChatWidget buildPieChatWidget() { 49 | return PieChatWidget( 50 | dataList: _dataList, 51 | //是否输出日志 52 | isLog: true, 53 | //是否需要背景 54 | isBackground: true, 55 | //是否画直线 56 | isLineText: true, 57 | //背景 58 | bgColor: Colors.white, 59 | //是否显示最前面的内容 60 | isFrontgText: true, 61 | //默认选择放大的块 62 | initSelect: 1, 63 | //初次显示以动画方式展开 64 | openType: OpenType.ANI, 65 | //旋转类型 66 | loopType: LoopType.DOWN_LOOP, 67 | //点击回调 68 | clickCallBack: (int value) { 69 | print("当前点击显示 $value"); 70 | }, 71 | ); 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /lib/src/pages/demo/demo_sign_swip.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/cupertino.dart'; 2 | import 'package:flutter/material.dart'; 3 | 4 | /// 创建人: Created by zhaolong 5 | /// 创建时间:Created by on 2021/1/11. 6 | /// 7 | /// 可关注公众号:我的大前端生涯 获取最新技术分享 8 | /// 可关注网易云课堂:https://study.163.com/instructor/1021406098.htm 9 | /// 可关注博客:https://blog.csdn.net/zl18603543572 10 | /// 11 | 12 | main() { 13 | runApp(MaterialApp( 14 | home: SignSwiperPage(), 15 | )); 16 | } 17 | 18 | class SignSwiperPage extends StatefulWidget { 19 | @override 20 | _SignSwiperPageState createState() => _SignSwiperPageState(); 21 | } 22 | 23 | class _SignSwiperPageState extends State 24 | with SingleTickerProviderStateMixin { 25 | //动画控制器 26 | late AnimationController _animationController; 27 | 28 | @override 29 | void initState() { 30 | super.initState(); 31 | 32 | //创建 33 | _animationController = new AnimationController( 34 | vsync: this, duration: Duration(milliseconds: 2000)); 35 | //添加到事件队列中 36 | Future.delayed(Duration.zero, () { 37 | //动画重复执行 38 | _animationController.repeat(); 39 | }); 40 | } 41 | 42 | @override 43 | void dispose() { 44 | //销毁 45 | _animationController.dispose(); 46 | super.dispose(); 47 | } 48 | 49 | @override 50 | Widget build(BuildContext context) { 51 | return Scaffold( 52 | appBar: AppBar( 53 | title: Text("Swiper Demo"), 54 | ), 55 | backgroundColor: Colors.white, 56 | //居中 57 | body: Center( 58 | //层叠布局 59 | child: Stack( 60 | children: [ 61 | //第一层的背景 圆形剪裁 62 | ClipOval( 63 | child: Container( 64 | width: 200, 65 | height: 200, 66 | color: Colors.green, 67 | ), 68 | ), 69 | //第二层的扫描 70 | buildRotationTransition(), 71 | ], 72 | ), 73 | ), 74 | ); 75 | } 76 | 77 | RotationTransition buildRotationTransition() { 78 | //旋转动画 79 | return RotationTransition( 80 | //动画控制器 81 | turns: _animationController, 82 | //圆形裁剪 83 | child: ClipOval( 84 | //扫描渐变 85 | child: Container( 86 | width: 200, 87 | height: 200, 88 | decoration: BoxDecoration( 89 | //扫描渐变 90 | gradient: SweepGradient(colors: [ 91 | Colors.white.withOpacity(0.2), 92 | Colors.white.withOpacity(0.6), 93 | ]), 94 | ), 95 | ), 96 | ), 97 | ); 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /lib/src/pages/demo/model/demo_model.dart: -------------------------------------------------------------------------------- 1 | /// 创建人: Created by zhaolong 2 | /// 创建时间:Created by on 2021/1/15. 3 | /// 4 | /// 可关注公众号:我的大前端生涯 获取最新技术分享 5 | /// 可关注网易云课堂:https://study.163.com/instructor/1021406098.htm 6 | /// 可关注博客:https://blog.csdn.net/zl18603543572 7 | /// 8 | /// 代码清单 9 | ///代码清单 10 | class DemoDataModel { 11 | 12 | } 13 | -------------------------------------------------------------------------------- /lib/src/pages/demo/widget/demo_PhysicalModel.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/cupertino.dart'; 2 | import 'package:flutter/material.dart'; 3 | 4 | /// 创建人: Created by zhaolong 5 | /// 创建时间:Created by on 3/26/21. 6 | /// 7 | /// 可关注公众号:我的大前端生涯 获取最新技术分享 8 | /// 可关注网易云课堂:https://study.163.com/instructor/1021406098.htm 9 | /// 可关注博客:https://blog.csdn.net/zl18603543572 10 | /// 11 | main() { 12 | runApp(MaterialApp( 13 | debugShowCheckedModeBanner: false, 14 | home: DemoPhysicalModel(), 15 | )); 16 | } 17 | 18 | ///代码清单 19 | class DemoPhysicalModel extends StatefulWidget { 20 | @override 21 | _DemoPhysicalModelState createState() => _DemoPhysicalModelState(); 22 | } 23 | 24 | class _DemoPhysicalModelState extends State { 25 | int _currentIndex = 0; 26 | Color _shadowColor = Colors.deepPurple; 27 | 28 | @override 29 | Widget build(BuildContext context) { 30 | return Scaffold( 31 | appBar: AppBar( 32 | title: Text("PhysicalModel 自定义阴影"), 33 | ), 34 | backgroundColor: Colors.white, 35 | body: Center( 36 | child: buildAnimatedPhysicalModel(), 37 | ), 38 | ); 39 | } 40 | 41 | AnimatedPhysicalModel buildAnimatedPhysicalModel() { 42 | return AnimatedPhysicalModel( 43 | //阴影的圆角 44 | borderRadius: BorderRadius.all(Radius.circular(0)), 45 | //阴影形状 默认矩形 46 | shape: BoxShape.rectangle, 47 | //背景颜色 48 | color: Colors.transparent, 49 | animateColor: true, 50 | //阴影颜色 51 | shadowColor: _shadowColor, 52 | animateShadowColor: true, 53 | //阴影高度 默认为0 54 | elevation: 1.0, 55 | //动态切换的时间 56 | duration: Duration(milliseconds: 1200), 57 | child: Text("早起的年轻人"), 58 | ); 59 | } 60 | 61 | ///[PhysicalModel]的基本使用 62 | Widget buildPhysicalModel() { 63 | return PhysicalModel( 64 | //阴影的圆角 65 | borderRadius: BorderRadius.all(Radius.circular(10)), 66 | //阴影形状 默认矩形 67 | shape: BoxShape.rectangle, 68 | //背景颜色 69 | color: Colors.deepPurple, 70 | //阴影颜色 71 | shadowColor: Colors.orange, 72 | //阴影高度 默认为0 73 | elevation: 20.0, 74 | child: Container( 75 | width: 200, 76 | height: 200, 77 | color: Colors.white, 78 | ), 79 | ); 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /lib/src/pages/demo/widget/demo_RotatedBox.dart: -------------------------------------------------------------------------------- 1 | import 'dart:math'; 2 | 3 | import 'package:flutter/cupertino.dart'; 4 | import 'package:flutter/material.dart'; 5 | 6 | /// 创建人: Created by zhaolong 7 | /// 创建时间:Created by on 3/26/21. 8 | /// 9 | /// 可关注公众号:我的大前端生涯 获取最新技术分享 10 | /// 可关注网易云课堂:https://study.163.com/instructor/1021406098.htm 11 | /// 可关注博客:https://blog.csdn.net/zl18603543572 12 | /// 13 | main() { 14 | runApp(MaterialApp( 15 | debugShowCheckedModeBanner: false, 16 | home: DemoRotatedBoxPage(), 17 | )); 18 | } 19 | 20 | ///代码清单 21 | class DemoRotatedBoxPage extends StatefulWidget { 22 | @override 23 | _DemoRotatedBoxPageState createState() => _DemoRotatedBoxPageState(); 24 | } 25 | 26 | class _DemoRotatedBoxPageState extends State { 27 | @override 28 | Widget build(BuildContext context) { 29 | return Scaffold( 30 | appBar: AppBar( 31 | title: Text("RotatedBox 旋转"), 32 | ), 33 | backgroundColor: Colors.white, 34 | 35 | ///填充布局 36 | body: Container( 37 | padding: EdgeInsets.only(top: 100, left: 100, right: 100), 38 | child: Row( 39 | children: [buildTransform()], 40 | ), 41 | ), 42 | ); 43 | } 44 | 45 | buildTransform() { 46 | return Transform.rotate( 47 | //旋转的弧度 48 | angle: pi/2, 49 | //旋转的子Widget 50 | child: Container( 51 | child: Text( 52 | 'Hello World!', 53 | style: TextStyle( 54 | color: Colors.white, 55 | ), 56 | ), 57 | color: Colors.blueGrey, 58 | ), 59 | ); 60 | } 61 | 62 | buildRotate() { 63 | return RotatedBox( 64 | //旋转的倍数 65 | quarterTurns: 1, 66 | //旋转的子Widget 67 | child: Container( 68 | child: Text( 69 | 'Hello World!', 70 | style: TextStyle( 71 | color: Colors.white, 72 | ), 73 | ), 74 | color: Colors.blueGrey, 75 | ), 76 | ); 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /lib/src/pages/demo/widget/demo_Slidable.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/cupertino.dart'; 2 | import 'package:flutter/material.dart'; 3 | import 'package:flutter_slidable/flutter_slidable.dart'; 4 | 5 | /// 创建人: Created by zhaolong 6 | /// 创建时间:Created by on 3/26/21. 7 | /// 8 | /// 可关注公众号:我的大前端生涯 获取最新技术分享 9 | /// 可关注网易云课堂:https://study.163.com/instructor/1021406098.htm 10 | /// 可关注博客:https://blog.csdn.net/zl18603543572 11 | /// 12 | 13 | -------------------------------------------------------------------------------- /lib/src/pages/home/list_item2_widget.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | 3 | import 'package:flutter/cupertino.dart'; 4 | import 'package:flutter/material.dart'; 5 | import 'package:flutter_ho/src/pages/play/video_details2_widget.dart'; 6 | 7 | /// 创建人: Created by zhaolong 8 | /// 创建时间:Created by on 2020/12/14. 9 | /// 10 | /// 可关注公众号:我的大前端生涯 获取最新技术分享 11 | /// 可关注网易云课堂:https://study.163.com/instructor/1021406098.htm 12 | /// 可关注博客:https://blog.csdn.net/zl18603543572 13 | /// 14 | /// 代码清单 15 | ///代码清单 16 | class ListViewItem2Widget extends StatefulWidget { 17 | final StreamController streamController; 18 | final isScroll; 19 | 20 | ListViewItem2Widget({required this.streamController, this.isScroll = false}); 21 | 22 | @override 23 | _ListViewItem2WidgetState createState() => _ListViewItem2WidgetState(); 24 | } 25 | 26 | class _ListViewItem2WidgetState extends State { 27 | @override 28 | Widget build(BuildContext context) { 29 | return Container( 30 | margin: EdgeInsets.only(top: 2), 31 | padding: EdgeInsets.all(8), 32 | color: Colors.white, 33 | child: Container( 34 | height: 220, 35 | child: buildVideoWidget(), 36 | ), 37 | ); 38 | } 39 | 40 | Widget buildVideoWidget() { 41 | if (widget.isScroll) { 42 | return Container( 43 | width: MediaQuery.of(context).size.width, 44 | child: Image.asset( 45 | "assets/images/welcome.png", 46 | fit: BoxFit.fitWidth, 47 | ), 48 | ); 49 | } 50 | return VideoDetails2Widget( 51 | streamController: widget.streamController, 52 | ); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /lib/src/pages/home/list_item_widget.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | 3 | import 'package:flutter/cupertino.dart'; 4 | import 'package:flutter/material.dart'; 5 | import 'package:flutter_ho/src/pages/play/video_details_widget.dart'; 6 | 7 | /// 创建人: Created by zhaolong 8 | /// 创建时间:Created by on 2020/12/14. 9 | /// 10 | /// 可关注公众号:我的大前端生涯 获取最新技术分享 11 | /// 可关注网易云课堂:https://study.163.com/instructor/1021406098.htm 12 | /// 可关注博客:https://blog.csdn.net/zl18603543572 13 | /// 14 | /// 代码清单 15 | ///代码清单 16 | class ListViewItemWidget extends StatefulWidget { 17 | final StreamController streamController; 18 | final isScroll; 19 | 20 | ListViewItemWidget({required this.streamController, this.isScroll = false}); 21 | 22 | @override 23 | _ListViewItemWidgetState createState() => _ListViewItemWidgetState(); 24 | } 25 | 26 | class _ListViewItemWidgetState extends State { 27 | @override 28 | Widget build(BuildContext context) { 29 | return Container( 30 | margin: EdgeInsets.only(top: 2), 31 | padding: EdgeInsets.all(8), 32 | color: Colors.white, 33 | child: Column( 34 | crossAxisAlignment: CrossAxisAlignment.start, 35 | children: [ 36 | Row( 37 | children: [Icon(Icons.one_k), Text("早起的年轻人")], 38 | ), 39 | SizedBox( 40 | height: 8, 41 | ), 42 | Container( 43 | height: 220, 44 | child: buildVideoWidget(), 45 | ) 46 | ], 47 | ), 48 | ); 49 | } 50 | 51 | Widget buildVideoWidget() { 52 | if (widget.isScroll) { 53 | return Container( 54 | width: MediaQuery.of(context).size.width, 55 | child: Image.asset( 56 | "assets/images/welcome.png", 57 | fit: BoxFit.fitWidth, 58 | ), 59 | ); 60 | } 61 | return VideoDetailsWidget( 62 | streamController: widget.streamController, 63 | ); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /lib/src/pages/login/bg/bubble_bean.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/cupertino.dart'; 2 | import 'package:flutter/material.dart'; 3 | 4 | /// 创建人: Created by zhaolong 5 | /// 创建时间:Created by on 2020/12/4. 6 | /// 7 | /// 可关注公众号:我的大前端生涯 获取最新技术分享 8 | /// 可关注网易云课堂:https://study.163.com/instructor/1021406098.htm 9 | /// 可关注博客:https://blog.csdn.net/zl18603543572 10 | /// 11 | /// 代码清单 12 | ///代码清单 13 | ///气泡属性配置 14 | class BobbleBean { 15 | //位置 16 | late Offset postion; 17 | 18 | //颜色 19 | late Color color; 20 | 21 | //运动的速度 22 | late double speed; 23 | 24 | //角度 25 | late double theta; 26 | 27 | //半径 28 | late double radius; 29 | } 30 | -------------------------------------------------------------------------------- /lib/src/pages/login/bg/bubble_painter.dart: -------------------------------------------------------------------------------- 1 | import 'dart:math'; 2 | 3 | import 'package:flutter/cupertino.dart'; 4 | import 'package:flutter/material.dart'; 5 | 6 | import 'bubble_bean.dart'; 7 | 8 | /// 创建人: Created by zhaolong 9 | /// 创建时间:Created by on 2020/12/4. 10 | /// 11 | /// 可关注公众号:我的大前端生涯 获取最新技术分享 12 | /// 可关注网易云课堂:https://study.163.com/instructor/1021406098.htm 13 | /// 可关注博客:https://blog.csdn.net/zl18603543572 14 | /// 15 | /// 代码清单 16 | ///绘制气泡的画布 17 | ///lib/src/page/login/bg/bubble_painter.dart 18 | class CustomMyPainter extends CustomPainter { 19 | //创建画笔 20 | Paint _paint = Paint(); 21 | //保存气泡的集合 22 | List list; 23 | //随机数变量 24 | Random random; 25 | CustomMyPainter({required this.list, required this.random}); 26 | 27 | ///计算坐标 28 | Offset calculateXY(double speed, double theta) { 29 | return Offset(speed * cos(theta), speed * sin(theta)); 30 | } 31 | 32 | @override 33 | void paint(Canvas canvas, Size size) { 34 | //每次绘制都重新计算位置 35 | list.forEach((element) { 36 | //计算偏移 37 | var velocity = calculateXY(element.speed, element.theta); 38 | //新的坐标 微偏移 39 | var dx = element.postion.dx + velocity.dx; 40 | var dy = element.postion.dy + velocity.dy; 41 | //x轴边界计算 42 | if (element.postion.dx < 0 || element.postion.dx > size.width) { 43 | dx = random.nextDouble() * size.width; 44 | } 45 | //y轴边界计算 46 | if (element.postion.dy < 0 || element.postion.dy > size.height) { 47 | dy = random.nextDouble() * size.height; 48 | } 49 | //新的位置 50 | element.postion = Offset(dx, dy); 51 | 52 | //print("dx $dx dy $dy ${element.postion}"); 53 | }); 54 | 55 | //循环绘制所有的气泡 56 | list.forEach((element) { 57 | //画笔颜色 58 | _paint.color = element.color; 59 | //绘制圆 60 | canvas.drawCircle(element.postion, element.radius, _paint); 61 | }); 62 | } 63 | 64 | @override 65 | bool shouldRepaint(covariant CustomPainter oldDelegate) { 66 | return true; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /lib/src/pages/mine/mine_login_page.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/cupertino.dart'; 2 | import 'package:flutter/material.dart'; 3 | import 'package:flutter/services.dart'; 4 | 5 | /// 创建人: Created by zhaolong 6 | /// 创建时间:Created by on 2020/12/23. 7 | /// 8 | /// 可关注公众号:我的大前端生涯 获取最新技术分享 9 | /// 可关注网易云课堂:https://study.163.com/instructor/1021406098.htm 10 | /// 可关注博客:https://blog.csdn.net/zl18603543572 11 | /// 12 | /// 代码清单 13 | ///用户未登录的用户中心 14 | class MineLoginPage extends StatefulWidget { 15 | @override 16 | _MineLoginPageState createState() => _MineLoginPageState(); 17 | } 18 | 19 | class _MineLoginPageState extends State { 20 | @override 21 | Widget build(BuildContext context) { 22 | return AnnotatedRegion( 23 | value: SystemUiOverlayStyle( 24 | statusBarBrightness: Brightness.dark, 25 | statusBarColor: Color(0XffCDDEEC), 26 | ), 27 | child: Scaffold( 28 | //填充布局 29 | body: Container( 30 | width: double.infinity, 31 | height: double.infinity, 32 | child: buildStack()), 33 | ), 34 | ); 35 | } 36 | 37 | Stack buildStack() { 38 | return Stack( 39 | children: [ 40 | Positioned.fill(child: buildBackgroundWidget()), 41 | ], 42 | ); 43 | } 44 | 45 | Container buildBackgroundWidget() { 46 | return Container( 47 | decoration: BoxDecoration( 48 | gradient: LinearGradient( 49 | begin: Alignment.topLeft, 50 | end: Alignment.bottomRight, 51 | colors: [ 52 | Colors.lightBlueAccent.withOpacity(0.3), 53 | Colors.blue.withOpacity(0.3), 54 | ])), 55 | ); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /lib/src/root_app_page.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/cupertino.dart'; 2 | import 'package:flutter/material.dart'; 3 | import 'package:flutter_ho/src/pages/demo/demo38/demo_demo_TweenAnimatedBuilder.dart'; 4 | 5 | import 'index_page.dart'; 6 | 7 | /// 创建人: Created by zhaolong 8 | /// 创建时间:Created by on 2020/12/7. 9 | /// 10 | /// 可关注公众号:我的大前端生涯 获取最新技术分享 11 | /// 可关注网易云课堂:https://study.163.com/instructor/1021406098.htm 12 | /// 可关注博客:https://blog.csdn.net/zl18603543572 13 | /// 14 | /// 代码清单 15 | 16 | class RootAPP extends StatefulWidget { 17 | @override 18 | State createState() { 19 | return _RootAPPState(); 20 | } 21 | } 22 | 23 | class _RootAPPState extends State { 24 | @override 25 | Widget build(BuildContext context) { 26 | return MaterialApp( 27 | theme: ThemeData( 28 | primaryColor: Colors.lightBlueAccent, 29 | bottomAppBarTheme: BottomAppBarTheme(color: Colors.blue)), 30 | //不显示 debug 标签 31 | debugShowCheckedModeBanner: false, 32 | home: DemoAnimatedTweenPage(), 33 | // home: IndexPage(), 34 | ); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /lib/src/test/test_demo.dart: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhaolongs/flutter-ho/d7e4bd24d5325aa896ea96725fc851044b003b00/lib/src/test/test_demo.dart -------------------------------------------------------------------------------- /lib/src/utils/aes_utils.dart: -------------------------------------------------------------------------------- 1 | 2 | import 'package:encrypt/encrypt.dart'; 3 | 4 | /// 创建人: Created by zhaolong 5 | /// 创建时间:Created by on 5/14/21. 6 | /// 7 | /// 可关注公众号:我的大前端生涯 获取最新技术分享 8 | /// 可关注网易云课堂:https://study.163.com/instructor/1021406098.htm 9 | /// 可关注博客:https://blog.csdn.net/zl18603543572 10 | /// 11 | /// 代码清单 12 | ///代码清单 13 | 14 | class EncryptUtils { 15 | //AES加密 16 | static aesEncrypt(String plainText, String keyStr, String ivStr) { 17 | try { 18 | final key = Key.fromUtf8(keyStr); 19 | final iv = IV.fromUtf8(ivStr); 20 | final encrypter = Encrypter(AES(key, mode: AESMode.cbc)); 21 | final encrypted = encrypter.encrypt(plainText, iv: iv); 22 | return encrypted.base64; 23 | } catch (err) { 24 | print("aes encode error:$err"); 25 | return plainText; 26 | } 27 | } 28 | 29 | //AES解密 30 | static dynamic aesDecrypt(encrypted, String keyStr, String ivStr) { 31 | try { 32 | final key = Key.fromUtf8(keyStr); 33 | final iv = IV.fromUtf8(ivStr); 34 | final encrypter = Encrypter(AES(key, mode: AESMode.cbc)); 35 | final decrypted = encrypter.decrypt64(encrypted, iv: iv); 36 | return decrypted; 37 | } catch (err) { 38 | print("aes decode error:$err"); 39 | return encrypted; 40 | } 41 | } 42 | } -------------------------------------------------------------------------------- /lib/src/utils/color_utils.dart: -------------------------------------------------------------------------------- 1 | import 'dart:math'; 2 | 3 | import 'package:flutter/cupertino.dart'; 4 | import 'package:flutter/material.dart'; 5 | 6 | /// 创建人: Created by zhaolong 7 | /// 创建时间:Created by on 2020/6/26. 8 | /// 9 | /// 创建人: Created by zhaolong 10 | /// 创建时间:Created by on 2020/9/25. 11 | /// 12 | /// gongzhonghao biglead 13 | /// https://study.163.com/instructor/1021406098.htm 14 | /// https://blog.csdn.net/zl18603543572 15 | /// https://www.toutiao.com/c/user/token/MS4wLjABAAAAYMrKikomuQJ4d-cPaeBqtAK2cQY697Pv9xIyyDhtwIM/ 16 | 17 | ///颜色工具类 18 | ///lib/utils/color_utils.dart 19 | class ColorUtils { 20 | ///获取随机颜色 21 | static Color getRandomColor() { 22 | return Color.fromARGB( 23 | 255, 24 | Random.secure().nextInt(200), 25 | Random.secure().nextInt(200), 26 | Random.secure().nextInt(200), 27 | ); 28 | } 29 | 30 | ///十六进制记法 #FF000000 取值范围为:00 - FF。 31 | ///RGB色彩是通过对红(R)、绿(G)、蓝(B) 32 | /// 三个颜色通道的变化和它们相互之间的叠加来得到各式各样的颜色的。 33 | ///RGBA此色彩模式与RGB相同,只是在RGB模式上新增了Alpha透明度。 34 | 35 | ///获取随机透明的白色 36 | static Color getRandonWhightColor(Random random) { 37 | //0~255 0为完全透明 255 为不透明 38 | //这里生成的透明度取值范围为 10~200 39 | int a = random.nextInt(190) + 10; 40 | return Color.fromARGB(a, 255, 255, 255); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /lib/src/utils/gzip_utils.dart: -------------------------------------------------------------------------------- 1 | import 'dart:convert'; 2 | 3 | import 'package:archive/archive.dart'; 4 | 5 | class GzipUtils { 6 | ///GZIP 压缩 7 | static String gzipEncode(String str) { 8 | //先来转换一下 9 | List stringBytes = utf8.encode(str); 10 | //然后使用 gzip 压缩 11 | List? gzipBytes = new GZipEncoder().encode(stringBytes); 12 | //然后再编码一下进行网络传输 13 | String compressedString = base64UrlEncode(gzipBytes!); 14 | return compressedString; 15 | } 16 | 17 | ///GZIP 解压缩 18 | static String gzipDencode(String str) { 19 | //先来解码一下 20 | List stringBytes = base64Url.decode(str); 21 | //然后使用 gzip 压缩 22 | List gzipBytes = new GZipDecoder().decodeBytes(stringBytes); 23 | //然后再编码一下 24 | String compressedString = utf8.decode(gzipBytes); 25 | return compressedString; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /lib/src/utils/log_utils.dart: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | /// 创建人: Created by zhaolong 5 | /// 创建时间:Created by on 2020/12/10. 6 | /// 7 | /// 可关注公众号:我的大前端生涯 获取最新技术分享 8 | /// 可关注网易云课堂:https://study.163.com/instructor/1021406098.htm 9 | /// 可关注博客:https://blog.csdn.net/zl18603543572 10 | /// 11 | /// 代码清单 12 | ///代码清单 13 | class LogUtils { 14 | 15 | //是否输入日志标识 16 | static bool _isLog = true; 17 | static String _logFlag = "Flutter-Ho"; 18 | 19 | static void init({bool islog = false,String logFlag ="Flutter-Ho"}){ 20 | _isLog = islog; 21 | _logFlag = logFlag; 22 | } 23 | 24 | 25 | static void e(String message){ 26 | 27 | if(_isLog){ 28 | print("$_logFlag | $message"); 29 | } 30 | } 31 | 32 | } -------------------------------------------------------------------------------- /lib/src/utils/toast_utils.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:fluttertoast/fluttertoast.dart'; 3 | 4 | ///lib/utils/toast_utils.dart 5 | ///Toast工具类 6 | class ToastUtils { 7 | static void showToast(String message) { 8 | // 根据消息长度决定自动消失时间 9 | double multiplier = 0.5; 10 | double flag = message.length * 0.06 + 0.5; 11 | //计算显示时间 12 | int timeInSecForIos = (multiplier * flag).round(); 13 | //如果已显示 先取消已有的 14 | Fluttertoast.cancel(); 15 | //显示Toast 16 | Fluttertoast.showToast( 17 | backgroundColor: Colors.black54, 18 | msg: message, 19 | //显示的位置 20 | gravity: ToastGravity.CENTER, 21 | //只针对iOS生效的消失时间 22 | timeInSecForIosWeb: timeInSecForIos, 23 | ); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /lib/src/welcom_time_widget.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | 3 | import 'package:flutter/cupertino.dart'; 4 | import 'package:flutter/material.dart'; 5 | import 'package:flutter_ho/src/utils/log_utils.dart'; 6 | import 'package:flutter_ho/src/utils/navigator_utils.dart'; 7 | 8 | import 'home_page.dart'; 9 | 10 | /// 创建人: Created by zhaolong 11 | /// 创建时间:Created by on 2020/12/14. 12 | /// 13 | /// 可关注公众号:我的大前端生涯 获取最新技术分享 14 | /// 可关注网易云课堂:https://study.163.com/instructor/1021406098.htm 15 | /// 可关注博客:https://blog.csdn.net/zl18603543572 16 | /// 17 | /// 代码清单 18 | //倒计时功能 19 | class WelcomeTimeWidget extends StatefulWidget { 20 | @override 21 | _WelcomeTimeWidgetState createState() => _WelcomeTimeWidgetState(); 22 | } 23 | 24 | class _WelcomeTimeWidgetState extends State { 25 | int currentTime = 5; 26 | 27 | late Timer _timer; 28 | 29 | @override 30 | void initState() { 31 | super.initState(); 32 | 33 | //创建计时器 间隔1秒执行 34 | _timer = Timer.periodic(Duration(seconds: 1), (timer) { 35 | if (currentTime == 0) { 36 | //停止计时 去首页面 37 | _timer.cancel(); 38 | goHome(); 39 | return; 40 | } 41 | 42 | currentTime--; 43 | setState(() {}); 44 | // 每间隔1秒回调一下 45 | LogUtils.e("计时器回调"); 46 | }); 47 | } 48 | 49 | @override 50 | void dispose() { 51 | if (_timer.isActive) { 52 | _timer.cancel(); 53 | } 54 | super.dispose(); 55 | } 56 | 57 | @override 58 | Widget build(BuildContext context) { 59 | return GestureDetector( 60 | onTap: () { 61 | goHome(); 62 | }, 63 | child: buildContainer(), 64 | ); 65 | } 66 | 67 | Container buildContainer() { 68 | return Container( 69 | decoration: BoxDecoration( 70 | //边框样式设置 71 | border: Border.all(color: Colors.redAccent, width: 2), 72 | //边框圆角设置 73 | borderRadius: BorderRadius.all(Radius.circular(20))), 74 | //子Widget 居中 75 | alignment: Alignment.center, 76 | child: Text( 77 | "${currentTime}s", 78 | style: TextStyle( 79 | fontWeight: FontWeight.w500, 80 | fontSize: 16, 81 | color: Colors.redAccent, 82 | ), 83 | ), 84 | width: 100, 85 | height: 33, 86 | ); 87 | } 88 | 89 | void goHome() { 90 | LogUtils.e("计时完成去首页面"); 91 | NavigatorUtils.pushPageByFade( 92 | context: context, 93 | targPage: HomePage(), 94 | isReplace: true, 95 | ); 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /lib/src/welcom_video_widget.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/cupertino.dart'; 2 | import 'package:flutter/material.dart'; 3 | import 'package:flutter_ho/src/utils/log_utils.dart'; 4 | import 'package:video_player/video_player.dart'; 5 | 6 | /// 创建人: Created by zhaolong 7 | /// 创建时间:Created by on 2020/12/14. 8 | /// 9 | /// 可关注公众号:我的大前端生涯 获取最新技术分享 10 | /// 可关注网易云课堂:https://study.163.com/instructor/1021406098.htm 11 | /// 可关注博客:https://blog.csdn.net/zl18603543572 12 | /// 13 | // 倒计时页面 的视频播放 14 | class WelcomeVideoWidget extends StatefulWidget { 15 | @override 16 | _WelcomeVideoWidgetState createState() => _WelcomeVideoWidgetState(); 17 | } 18 | 19 | class _WelcomeVideoWidgetState extends State { 20 | //创建视频播放控制器 21 | late VideoPlayerController _controller; 22 | 23 | @override 24 | void initState() { 25 | super.initState(); 26 | 27 | _controller = VideoPlayerController.asset('assets/video/welcom.mp4') 28 | ..initialize().then((_) { 29 | LogUtils.e("加载完成"); 30 | _controller.play(); 31 | // Ensure the first frame is shown after the video is initialized, even before the play button has been pressed. 32 | setState(() {}); 33 | }); 34 | } 35 | 36 | @override 37 | Widget build(BuildContext context) { 38 | return _controller.value.isInitialized 39 | ? SizedBox( 40 | width: MediaQuery.of(context).size.width, 41 | height: MediaQuery.of(context).size.height, 42 | child: AspectRatio( 43 | aspectRatio: _controller.value.aspectRatio, 44 | child: VideoPlayer(_controller), 45 | ), 46 | ) 47 | : Container(); 48 | } 49 | 50 | @override 51 | void dispose() { 52 | super.dispose(); 53 | _controller.dispose(); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /lib/src/welcome_page.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/cupertino.dart'; 2 | import 'package:flutter/material.dart'; 3 | import 'package:flutter_ho/src/welcom_video_widget.dart'; 4 | 5 | import 'welcom_time_widget.dart'; 6 | 7 | /// 创建人: Created by zhaolong 8 | /// 创建时间:Created by on 2020/12/14. 9 | /// 10 | /// 可关注公众号:我的大前端生涯 获取最新技术分享 11 | /// 可关注网易云课堂:https://study.163.com/instructor/1021406098.htm 12 | /// 可关注博客:https://blog.csdn.net/zl18603543572 13 | /// 14 | /// 代码清单 15 | ///倒计时页面 16 | class WelcomePage extends StatefulWidget { 17 | @override 18 | _WelcomePageState createState() => _WelcomePageState(); 19 | } 20 | 21 | class _WelcomePageState extends State { 22 | @override 23 | Widget build(BuildContext context) { 24 | //全屏展示 25 | return Scaffold( 26 | body: Container( 27 | width: double.infinity, 28 | height: double.infinity, 29 | child: Stack( 30 | children: [ 31 | //第一层 背景 可以是一个图片 32 | //也可以是一个视频播放 33 | Positioned.fill( 34 | child: Hero( 35 | tag: "welcom1", 36 | child: Material( 37 | color: Colors.transparent, 38 | child: WelcomeVideoWidget(), 39 | ), 40 | ), 41 | ), 42 | //第二层就是倒计时功能 43 | //右下角对齐 44 | Positioned( 45 | child: WelcomeTimeWidget(), 46 | right: 20, 47 | bottom: 66, 48 | ) 49 | ], 50 | )), 51 | ); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /linux/.gitignore: -------------------------------------------------------------------------------- 1 | flutter/ephemeral 2 | -------------------------------------------------------------------------------- /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 | set(PLUGIN_BUNDLED_LIBRARIES) 9 | 10 | foreach(plugin ${FLUTTER_PLUGIN_LIST}) 11 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/linux plugins/${plugin}) 12 | target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) 13 | list(APPEND PLUGIN_BUNDLED_LIBRARIES $) 14 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) 15 | endforeach(plugin) 16 | -------------------------------------------------------------------------------- /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.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 package_info 9 | import path_provider_macos 10 | import shared_preferences_macos 11 | 12 | func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { 13 | FLTPackageInfoPlugin.register(with: registry.registrar(forPlugin: "FLTPackageInfoPlugin")) 14 | PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin")) 15 | SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin")) 16 | } 17 | -------------------------------------------------------------------------------- /macos/Podfile: -------------------------------------------------------------------------------- 1 | platform :osx, '10.11' 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 | end 35 | 36 | post_install do |installer| 37 | installer.pods_project.targets.each do |target| 38 | flutter_additional_macos_build_settings(target) 39 | end 40 | end 41 | -------------------------------------------------------------------------------- /macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /macos/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /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/zhaolongs/flutter-ho/d7e4bd24d5325aa896ea96725fc851044b003b00/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhaolongs/flutter-ho/d7e4bd24d5325aa896ea96725fc851044b003b00/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhaolongs/flutter-ho/d7e4bd24d5325aa896ea96725fc851044b003b00/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhaolongs/flutter-ho/d7e4bd24d5325aa896ea96725fc851044b003b00/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhaolongs/flutter-ho/d7e4bd24d5325aa896ea96725fc851044b003b00/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhaolongs/flutter-ho/d7e4bd24d5325aa896ea96725fc851044b003b00/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhaolongs/flutter-ho/d7e4bd24d5325aa896ea96725fc851044b003b00/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_ho 9 | 10 | // The application's bundle identifier 11 | PRODUCT_BUNDLE_IDENTIFIER = com.studyyoun.flutterHo 12 | 13 | // The copyright displayed in application information 14 | PRODUCT_COPYRIGHT = Copyright © 2022 com.studyyoun. 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 | -------------------------------------------------------------------------------- /test/widget_test.dart: -------------------------------------------------------------------------------- 1 | // This is a basic Flutter widget test. 2 | // 3 | // To perform an interaction with a widget in your test, use the WidgetTester 4 | // utility that Flutter provides. For example, you can send tap and scroll 5 | // gestures. You can also use WidgetTester to find child widgets in the widget 6 | // tree, read text, and verify that the values of widget properties are correct. 7 | 8 | import 'dart:js'; 9 | 10 | import 'package:flutter/material.dart'; 11 | import 'package:flutter_test/flutter_test.dart'; 12 | 13 | import 'package:flutter_ho/main.dart'; 14 | 15 | void main() { 16 | testWidgets('Counter increments smoke test', (WidgetTester tester) async { 17 | 18 | 19 | }); 20 | } 21 | -------------------------------------------------------------------------------- /web/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhaolongs/flutter-ho/d7e4bd24d5325aa896ea96725fc851044b003b00/web/favicon.png -------------------------------------------------------------------------------- /web/icons/Icon-192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhaolongs/flutter-ho/d7e4bd24d5325aa896ea96725fc851044b003b00/web/icons/Icon-192.png -------------------------------------------------------------------------------- /web/icons/Icon-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhaolongs/flutter-ho/d7e4bd24d5325aa896ea96725fc851044b003b00/web/icons/Icon-512.png -------------------------------------------------------------------------------- /web/icons/Icon-maskable-192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhaolongs/flutter-ho/d7e4bd24d5325aa896ea96725fc851044b003b00/web/icons/Icon-maskable-192.png -------------------------------------------------------------------------------- /web/icons/Icon-maskable-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhaolongs/flutter-ho/d7e4bd24d5325aa896ea96725fc851044b003b00/web/icons/Icon-maskable-512.png -------------------------------------------------------------------------------- /web/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "flutter_ho", 3 | "short_name": "flutter_ho", 4 | "start_url": ".", 5 | "display": "standalone", 6 | "background_color": "#0175C2", 7 | "theme_color": "#0175C2", 8 | "description": "Flutter 快速开发模板", 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/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 | set(PLUGIN_BUNDLED_LIBRARIES) 10 | 11 | foreach(plugin ${FLUTTER_PLUGIN_LIST}) 12 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/windows plugins/${plugin}) 13 | target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) 14 | list(APPEND PLUGIN_BUNDLED_LIBRARIES $) 15 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) 16 | endforeach(plugin) 17 | -------------------------------------------------------------------------------- /windows/runner/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.14) 2 | project(runner LANGUAGES CXX) 3 | 4 | add_executable(${BINARY_NAME} WIN32 5 | "flutter_window.cpp" 6 | "main.cpp" 7 | "utils.cpp" 8 | "win32_window.cpp" 9 | "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" 10 | "Runner.rc" 11 | "runner.exe.manifest" 12 | ) 13 | apply_standard_settings(${BINARY_NAME}) 14 | target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX") 15 | target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app) 16 | target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") 17 | add_dependencies(${BINARY_NAME} flutter_assemble) 18 | -------------------------------------------------------------------------------- /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 | return true; 30 | } 31 | 32 | void FlutterWindow::OnDestroy() { 33 | if (flutter_controller_) { 34 | flutter_controller_ = nullptr; 35 | } 36 | 37 | Win32Window::OnDestroy(); 38 | } 39 | 40 | LRESULT 41 | FlutterWindow::MessageHandler(HWND hwnd, UINT const message, 42 | WPARAM const wparam, 43 | LPARAM const lparam) noexcept { 44 | // Give Flutter, including plugins, an opportunity to handle window messages. 45 | if (flutter_controller_) { 46 | std::optional result = 47 | flutter_controller_->HandleTopLevelWindowProc(hwnd, message, wparam, 48 | lparam); 49 | if (result) { 50 | return *result; 51 | } 52 | } 53 | 54 | switch (message) { 55 | case WM_FONTCHANGE: 56 | flutter_controller_->engine()->ReloadSystemFonts(); 57 | break; 58 | } 59 | 60 | return Win32Window::MessageHandler(hwnd, message, wparam, lparam); 61 | } 62 | -------------------------------------------------------------------------------- /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.CreateAndShow(L"flutter_ho", 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/zhaolongs/flutter-ho/d7e4bd24d5325aa896ea96725fc851044b003b00/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 | if (target_length == 0) { 52 | return std::string(); 53 | } 54 | std::string utf8_string; 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 | --------------------------------------------------------------------------------