├── .flutter-plugins-dependencies ├── .gitignore ├── .metadata ├── .vscode └── settings.json ├── README.md ├── android ├── app │ ├── build.gradle │ └── src │ │ ├── debug │ │ └── AndroidManifest.xml │ │ ├── main │ │ ├── AndroidManifest.xml │ │ ├── kotlin │ │ │ └── com │ │ │ │ └── example │ │ │ │ └── flutter_widget │ │ │ │ └── MainActivity.kt │ │ └── res │ │ │ ├── drawable │ │ │ └── launch_background.xml │ │ │ ├── mipmap-hdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-mdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xhdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxhdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxxhdpi │ │ │ └── ic_launcher.png │ │ │ └── values │ │ │ └── styles.xml │ │ └── profile │ │ └── AndroidManifest.xml ├── build.gradle ├── gradle.properties ├── gradle │ └── wrapper │ │ └── gradle-wrapper.properties ├── settings.gradle └── settings_aar.gradle ├── assets ├── Filip.flr ├── animation.flr └── loading_img.gif ├── ios ├── Flutter │ ├── .last_build_id │ ├── AppFrameworkInfo.plist │ ├── Debug.xcconfig │ ├── Flutter.podspec │ └── Release.xcconfig ├── Podfile ├── Podfile.lock ├── Runner.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ └── IDEWorkspaceChecks.plist │ └── xcshareddata │ │ └── xcschemes │ │ └── Runner.xcscheme ├── Runner.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ └── IDEWorkspaceChecks.plist └── Runner │ ├── AppDelegate.h │ ├── AppDelegate.m │ ├── AppDelegate.swift │ ├── Assets.xcassets │ ├── AppIcon.appiconset │ │ ├── Contents.json │ │ ├── Icon-App-1024x1024@1x.png │ │ ├── Icon-App-20x20@1x.png │ │ ├── Icon-App-20x20@2x.png │ │ ├── Icon-App-20x20@3x.png │ │ ├── Icon-App-29x29@1x.png │ │ ├── Icon-App-29x29@2x.png │ │ ├── Icon-App-29x29@3x.png │ │ ├── Icon-App-40x40@1x.png │ │ ├── Icon-App-40x40@2x.png │ │ ├── Icon-App-40x40@3x.png │ │ ├── Icon-App-60x60@2x.png │ │ ├── Icon-App-60x60@3x.png │ │ ├── Icon-App-76x76@1x.png │ │ ├── Icon-App-76x76@2x.png │ │ └── Icon-App-83.5x83.5@2x.png │ └── LaunchImage.imageset │ │ ├── Contents.json │ │ ├── LaunchImage.png │ │ ├── LaunchImage@2x.png │ │ ├── LaunchImage@3x.png │ │ └── README.md │ ├── AudioplayerPlugin.h │ ├── AudioplayerPlugin.m │ ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard │ ├── ConfigurationHelper.swift │ ├── Info.plist │ ├── Runner-Bridging-Header.h │ └── Runner.entitlements ├── lib ├── flutterApp.dart ├── helpers │ ├── audio.dart │ └── flutter_toast.dart ├── main.dart ├── routers │ ├── Animationted.dart │ ├── AppLifecycleListen.dart │ ├── AudioApp.dart │ ├── CollapseNavigation.dart │ ├── LoginVideo.dart │ ├── PlatformChannel.dart │ ├── SlideDown.dart │ ├── StackNavBar.dart │ ├── StickTab.dart │ ├── Swiper.dart │ ├── TabBarFixed.dart │ ├── UnlimitedHighCarousel.dart │ ├── VideoPictureInPicture.dart │ ├── carousel_zoom.dart │ └── fold_list.dart └── widgets │ ├── TabContainer.dart │ ├── stick_render.dart │ └── stick_widget.dart ├── picture ├── QRCode_258.png ├── Screenrecorder-2020-02-24-14-30-23-661.gif ├── Screenshot_2020-02-24-14-37-21-470_com.android.settings.jpg ├── app_lifecycle_listen.gif ├── auto_height_carousel.gif ├── collapse_navigation.gif ├── login_video_demo.gif ├── stack_navbar.gif ├── swipe.gif └── tapd_59861796_base64_1589612431_37.png ├── pubspec.lock ├── pubspec.yaml └── test └── widget_test.dart /.flutter-plugins-dependencies: -------------------------------------------------------------------------------- 1 | {"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"audioplayers","path":"/Users/aming/Applications/flutter/.pub-cache/hosted/pub.flutter-io.cn/audioplayers-0.15.1/","dependencies":["path_provider"]},{"name":"path_provider","path":"/Users/aming/Applications/flutter/.pub-cache/hosted/pub.flutter-io.cn/path_provider-1.6.16/","dependencies":[]},{"name":"video_player","path":"/Users/aming/Applications/flutter/.pub-cache/hosted/pub.flutter-io.cn/video_player-0.10.11+1/","dependencies":[]},{"name":"wakelock","path":"/Users/aming/Applications/flutter/.pub-cache/hosted/pub.flutter-io.cn/wakelock-0.1.4+2/","dependencies":[]}],"android":[{"name":"audioplayers","path":"/Users/aming/Applications/flutter/.pub-cache/hosted/pub.flutter-io.cn/audioplayers-0.15.1/","dependencies":["path_provider"]},{"name":"path_provider","path":"/Users/aming/Applications/flutter/.pub-cache/hosted/pub.flutter-io.cn/path_provider-1.6.16/","dependencies":[]},{"name":"video_player","path":"/Users/aming/Applications/flutter/.pub-cache/hosted/pub.flutter-io.cn/video_player-0.10.11+1/","dependencies":[]},{"name":"wakelock","path":"/Users/aming/Applications/flutter/.pub-cache/hosted/pub.flutter-io.cn/wakelock-0.1.4+2/","dependencies":[]}],"macos":[{"name":"audioplayers","path":"/Users/aming/Applications/flutter/.pub-cache/hosted/pub.flutter-io.cn/audioplayers-0.15.1/","dependencies":[]},{"name":"path_provider_macos","path":"/Users/aming/Applications/flutter/.pub-cache/hosted/pub.flutter-io.cn/path_provider_macos-0.0.4+4/","dependencies":[]}],"linux":[{"name":"path_provider_linux","path":"/Users/aming/Applications/flutter/.pub-cache/hosted/pub.flutter-io.cn/path_provider_linux-0.0.1+2/","dependencies":[]}],"windows":[{"name":"path_provider_windows","path":"/Users/aming/Applications/flutter/.pub-cache/hosted/pub.flutter-io.cn/path_provider_windows-0.0.3/","dependencies":[]}],"web":[{"name":"audioplayers","path":"/Users/aming/Applications/flutter/.pub-cache/hosted/pub.flutter-io.cn/audioplayers-0.15.1/","dependencies":[]},{"name":"video_player_web","path":"/Users/aming/Applications/flutter/.pub-cache/hosted/pub.flutter-io.cn/video_player_web-0.1.3+2/","dependencies":[]}]},"dependencyGraph":[{"name":"audioplayers","dependencies":["path_provider"]},{"name":"path_provider","dependencies":["path_provider_macos","path_provider_linux","path_provider_windows"]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_macos","dependencies":[]},{"name":"path_provider_windows","dependencies":[]},{"name":"video_player","dependencies":["video_player_web"]},{"name":"video_player_web","dependencies":[]},{"name":"wakelock","dependencies":[]}],"date_created":"2020-12-22 14:55:54.305157","version":"1.22.4"} -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | *.class 3 | *.log 4 | *.pyc 5 | *.swp 6 | .DS_Store 7 | .atom/ 8 | .buildlog/ 9 | .history 10 | .svn/ 11 | 12 | # IntelliJ related 13 | *.iml 14 | *.ipr 15 | *.iws 16 | .idea/ 17 | 18 | # The .vscode folder contains launch configuration and tasks you configure in 19 | # VS Code which you may wish to be included in version control, so this line 20 | # is commented out by default. 21 | #.vscode/ 22 | 23 | # Flutter/Dart/Pub related 24 | **/doc/api/ 25 | .dart_tool/ 26 | .flutter-plugins 27 | .packages 28 | .pub-cache/ 29 | .pub/ 30 | /build/ 31 | /picture/ppt/ 32 | 33 | # Android related 34 | **/android/**/gradle-wrapper.jar 35 | **/android/.gradle 36 | **/android/captures/ 37 | **/android/gradlew 38 | **/android/gradlew.bat 39 | **/android/local.properties 40 | **/android/**/GeneratedPluginRegistrant.java 41 | 42 | # iOS/XCode related 43 | **/ios/**/*.mode1v3 44 | **/ios/**/*.mode2v3 45 | **/ios/**/*.moved-aside 46 | **/ios/**/*.pbxuser 47 | **/ios/**/*.perspectivev3 48 | **/ios/**/*sync/ 49 | **/ios/**/.sconsign.dblite 50 | **/ios/**/.tags* 51 | **/ios/**/.vagrant/ 52 | **/ios/**/DerivedData/ 53 | **/ios/**/Icon? 54 | **/ios/**/Pods/ 55 | **/ios/**/.symlinks/ 56 | **/ios/**/profile 57 | **/ios/**/xcuserdata 58 | **/ios/.generated/ 59 | **/ios/Flutter/App.framework 60 | **/ios/Flutter/Flutter.framework 61 | **/ios/Flutter/Generated.xcconfig 62 | **/ios/Flutter/app.flx 63 | **/ios/Flutter/app.zip 64 | **/ios/Flutter/flutter_assets/ 65 | **/ios/Flutter/flutter_export_environment.sh 66 | **/ios/ServiceDefinitions.json 67 | **/ios/Runner/GeneratedPluginRegistrant.* 68 | 69 | # Exceptions to above rules. 70 | !**/ios/**/default.mode1v3 71 | !**/ios/**/default.mode2v3 72 | !**/ios/**/default.pbxuser 73 | !**/ios/**/default.perspectivev3 74 | !/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages 75 | -------------------------------------------------------------------------------- /.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: 1aedbb1835bd6eb44550293d57d4d124f19901f0 8 | channel: unknown 9 | 10 | project_type: app 11 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "cSpell.words": [ 3 | "audioplayer", 4 | "audioplayers", 5 | "hotfix" 6 | ] 7 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

Flutter 小案例(flutter_widget)

2 | 3 | ## 扫码下载 4 |

5 | 6 |

7 | 8 | ## Flutter版本(要注意版本比如1.20.4的版本跑iOS会报找不到引擎) 9 | 10 | ```dart 11 | Flutter 1.20.4 • channel stable • https://github.com/flutter/flutter.git 12 | Framework • revision fba99f6cf9 (6 days ago) • 2020-09-14 15:32:52 -0700 13 | Engine • revision d1bc06f032 14 | Tools • Dart 2.9.2 15 | ``` 16 | 17 | ## 视频背景登录(IOS播放请使用真机调试) 18 | 19 |

20 | 21 |

22 | 23 | ## 仿马蜂窝自适应高度轮播图 24 | 25 |

26 | 27 |

28 | 29 | ## 自定义滑动(类似开言英语轮播图) 30 |

31 | 32 |

33 | 34 | ## 滑动导航变色 35 |

36 | 37 |

38 | 39 | ## 滑动隐藏导航 40 |

41 | 42 |

43 | 44 | ## App状态监听 45 |

46 | 47 |

48 | 49 | ## 错误信息 50 | 51 | ### 打包IOS程序报错 52 | 53 | ```bash 54 | Warning: CocoaPods installed but not initialized. Skipping pod install. 55 | CocoaPods is used to retrieve the iOS and macOS platform side's plugin code that responds to your plugin usage on the Dart side. 56 | Without CocoaPods, plugins will not work on iOS or macOS. 57 | For more info, see https://flutter.dev/platform-plugins 58 | To initialize CocoaPods, run: 59 | pod setup 60 | once to finalize CocoaPods' installation. 61 | ``` 62 | 63 | ### M1芯片`Podfile`报架构问题 64 | 65 | ``` 66 | # M1芯片 67 | installer.pods_project.build_configurations.each do |config| 68 | config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64" 69 | end 70 | ``` 71 | 72 | ### 运行`pod setup` 73 | 74 | ```bash 75 | pod setup 76 | ``` 77 | 78 | -------------------------------------------------------------------------------- /android/app/build.gradle: -------------------------------------------------------------------------------- 1 | def localProperties = new Properties() 2 | def localPropertiesFile = rootProject.file('local.properties') 3 | if (localPropertiesFile.exists()) { 4 | localPropertiesFile.withReader('UTF-8') { reader -> 5 | localProperties.load(reader) 6 | } 7 | } 8 | 9 | def flutterRoot = localProperties.getProperty('flutter.sdk') 10 | if (flutterRoot == null) { 11 | throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") 12 | } 13 | 14 | def flutterVersionCode = localProperties.getProperty('flutter.versionCode') 15 | if (flutterVersionCode == null) { 16 | flutterVersionCode = '1' 17 | } 18 | 19 | def flutterVersionName = localProperties.getProperty('flutter.versionName') 20 | if (flutterVersionName == null) { 21 | flutterVersionName = '1.0' 22 | } 23 | 24 | apply plugin: 'com.android.application' 25 | apply plugin: 'kotlin-android' 26 | apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" 27 | 28 | android { 29 | compileSdkVersion 28 30 | 31 | sourceSets { 32 | main.java.srcDirs += 'src/main/kotlin' 33 | } 34 | 35 | lintOptions { 36 | disable 'InvalidPackage' 37 | } 38 | 39 | defaultConfig { 40 | // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). 41 | applicationId "com.example.flutter_widget" 42 | minSdkVersion 16 43 | targetSdkVersion 28 44 | versionCode flutterVersionCode.toInteger() 45 | versionName flutterVersionName 46 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 47 | } 48 | 49 | buildTypes { 50 | release { 51 | // TODO: Add your own signing config for the release build. 52 | // Signing with the debug keys for now, so `flutter run --release` works. 53 | signingConfig signingConfigs.debug 54 | } 55 | } 56 | } 57 | 58 | flutter { 59 | source '../..' 60 | } 61 | 62 | dependencies { 63 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" 64 | testImplementation 'junit:junit:4.12' 65 | androidTestImplementation 'androidx.test.ext:junit:1.1.1' 66 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0' 67 | } 68 | -------------------------------------------------------------------------------- /android/app/src/debug/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 9 | 10 | 17 | 21 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /android/app/src/main/kotlin/com/example/flutter_widget/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.example.flutter_widget 2 | 3 | import io.flutter.embedding.android.FlutterActivity; 4 | 5 | class MainActivity: FlutterActivity() { 6 | } 7 | -------------------------------------------------------------------------------- /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/Tecode/flutter_widget/3a22898c58114bd942162ca1fc7bbdcef9396430/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tecode/flutter_widget/3a22898c58114bd942162ca1fc7bbdcef9396430/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tecode/flutter_widget/3a22898c58114bd942162ca1fc7bbdcef9396430/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tecode/flutter_widget/3a22898c58114bd942162ca1fc7bbdcef9396430/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tecode/flutter_widget/3a22898c58114bd942162ca1fc7bbdcef9396430/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 9 | -------------------------------------------------------------------------------- /android/app/src/profile/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /android/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | ext.kotlin_version = '1.2.71' 3 | repositories { 4 | // google() 5 | // jcenter() 6 | maven { url 'https://maven.aliyun.com/repository/google' } 7 | maven { url 'https://maven.aliyun.com/repository/jcenter' } 8 | maven { url "https://maven.aliyun.com/nexus/content/groups/public/" } 9 | } 10 | 11 | dependencies { 12 | classpath 'com.android.tools.build:gradle:3.2.1' 13 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 14 | } 15 | } 16 | 17 | allprojects { 18 | repositories { 19 | // google() 20 | // jcenter() 21 | maven { url 'https://maven.aliyun.com/repository/google' } 22 | maven { url 'https://maven.aliyun.com/repository/jcenter' } 23 | maven { url "https://maven.aliyun.com/nexus/content/groups/public/" } 24 | } 25 | } 26 | 27 | rootProject.buildDir = '../build' 28 | subprojects { 29 | project.buildDir = "${rootProject.buildDir}/${project.name}" 30 | } 31 | subprojects { 32 | project.evaluationDependsOn(':app') 33 | } 34 | 35 | task clean(type: Delete) { 36 | delete rootProject.buildDir 37 | } 38 | -------------------------------------------------------------------------------- /android/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx1536M 2 | 3 | android.enableR8=true 4 | android.useAndroidX=true 5 | android.enableJetifier=true 6 | -------------------------------------------------------------------------------- /android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Fri Jun 23 08:50:38 CEST 2017 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip 7 | -------------------------------------------------------------------------------- /android/settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | 3 | def flutterProjectRoot = rootProject.projectDir.parentFile.toPath() 4 | 5 | def plugins = new Properties() 6 | def pluginsFile = new File(flutterProjectRoot.toFile(), '.flutter-plugins') 7 | if (pluginsFile.exists()) { 8 | pluginsFile.withReader('UTF-8') { reader -> plugins.load(reader) } 9 | } 10 | 11 | plugins.each { name, path -> 12 | def pluginDirectory = flutterProjectRoot.resolve(path).resolve('android').toFile() 13 | include ":$name" 14 | project(":$name").projectDir = pluginDirectory 15 | } 16 | -------------------------------------------------------------------------------- /android/settings_aar.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | -------------------------------------------------------------------------------- /assets/Filip.flr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tecode/flutter_widget/3a22898c58114bd942162ca1fc7bbdcef9396430/assets/Filip.flr -------------------------------------------------------------------------------- /assets/animation.flr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tecode/flutter_widget/3a22898c58114bd942162ca1fc7bbdcef9396430/assets/animation.flr -------------------------------------------------------------------------------- /assets/loading_img.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tecode/flutter_widget/3a22898c58114bd942162ca1fc7bbdcef9396430/assets/loading_img.gif -------------------------------------------------------------------------------- /ios/Flutter/.last_build_id: -------------------------------------------------------------------------------- 1 | a5e4acfe164ab6114f29b9c56c79a4b4 -------------------------------------------------------------------------------- /ios/Flutter/AppFrameworkInfo.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | App 9 | CFBundleIdentifier 10 | io.flutter.flutter.app 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | App 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1.0 23 | MinimumOSVersion 24 | 8.0 25 | 26 | 27 | -------------------------------------------------------------------------------- /ios/Flutter/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" 2 | #include "Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /ios/Flutter/Flutter.podspec: -------------------------------------------------------------------------------- 1 | # 2 | # NOTE: This podspec is NOT to be published. It is only used as a local source! 3 | # 4 | 5 | Pod::Spec.new do |s| 6 | s.name = 'Flutter' 7 | s.version = '1.0.0' 8 | s.summary = 'High-performance, high-fidelity mobile apps.' 9 | s.description = <<-DESC 10 | Flutter provides an easy and productive way to build and deploy high-performance mobile apps for Android and iOS. 11 | DESC 12 | s.homepage = 'https://flutter.io' 13 | s.license = { :type => 'MIT' } 14 | s.author = { 'Flutter Dev Team' => 'flutter-dev@googlegroups.com' } 15 | s.source = { :git => 'https://github.com/flutter/engine', :tag => s.version.to_s } 16 | s.ios.deployment_target = '8.0' 17 | s.vendored_frameworks = 'Flutter.framework' 18 | end 19 | -------------------------------------------------------------------------------- /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 | use_frameworks! 32 | use_modular_headers! 33 | 34 | flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__)) 35 | end 36 | 37 | post_install do |installer| 38 | installer.pods_project.targets.each do |target| 39 | flutter_additional_ios_build_settings(target) 40 | end 41 | end 42 | -------------------------------------------------------------------------------- /ios/Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - audioplayers (0.0.1): 3 | - Flutter 4 | - Flutter (1.0.0) 5 | - path_provider (0.0.1): 6 | - Flutter 7 | - video_player (0.0.1): 8 | - Flutter 9 | - wakelock (0.0.1): 10 | - Flutter 11 | 12 | DEPENDENCIES: 13 | - audioplayers (from `.symlinks/plugins/audioplayers/ios`) 14 | - Flutter (from `Flutter`) 15 | - path_provider (from `.symlinks/plugins/path_provider/ios`) 16 | - video_player (from `.symlinks/plugins/video_player/ios`) 17 | - wakelock (from `.symlinks/plugins/wakelock/ios`) 18 | 19 | EXTERNAL SOURCES: 20 | audioplayers: 21 | :path: ".symlinks/plugins/audioplayers/ios" 22 | Flutter: 23 | :path: Flutter 24 | path_provider: 25 | :path: ".symlinks/plugins/path_provider/ios" 26 | video_player: 27 | :path: ".symlinks/plugins/video_player/ios" 28 | wakelock: 29 | :path: ".symlinks/plugins/wakelock/ios" 30 | 31 | SPEC CHECKSUMS: 32 | audioplayers: 84f968cea3f2deab00ec4f8ff53358b3c0b3992c 33 | Flutter: 0e3d915762c693b495b44d77113d4970485de6ec 34 | path_provider: abfe2b5c733d04e238b0d8691db0cfd63a27a93c 35 | video_player: 9cc823b1d9da7e8427ee591e8438bfbcde500e6e 36 | wakelock: 0d4a70faf8950410735e3f61fb15d517c8a6efc4 37 | 38 | PODFILE CHECKSUM: aafe91acc616949ddb318b77800a7f51bffa2a4c 39 | 40 | COCOAPODS: 1.8.4 41 | -------------------------------------------------------------------------------- /ios/Runner.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; }; 11 | 31EB1B16C1FC2FF1E00B4150 /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1CD7E9ADAA6E473663EAECC8 /* Pods_Runner.framework */; }; 12 | 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; }; 13 | 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; }; 14 | 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; }; 15 | 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; }; 16 | 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; }; 17 | /* End PBXBuildFile section */ 18 | 19 | /* Begin PBXCopyFilesBuildPhase section */ 20 | 9705A1C41CF9048500538489 /* Embed Frameworks */ = { 21 | isa = PBXCopyFilesBuildPhase; 22 | buildActionMask = 2147483647; 23 | dstPath = ""; 24 | dstSubfolderSpec = 10; 25 | files = ( 26 | ); 27 | name = "Embed Frameworks"; 28 | runOnlyForDeploymentPostprocessing = 0; 29 | }; 30 | /* End PBXCopyFilesBuildPhase section */ 31 | 32 | /* Begin PBXFileReference section */ 33 | 144794647118CA68283DCB5C /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = ""; }; 34 | 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; }; 35 | 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; }; 36 | 1CD7E9ADAA6E473663EAECC8 /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 37 | 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; 38 | 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = ""; }; 39 | 74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 40 | 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; }; 41 | 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = ""; }; 42 | 9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = ""; }; 43 | 97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; }; 44 | 97C146FB1CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 45 | 97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 46 | 97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 47 | 97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 48 | C5903CB79AFF3A14E3193499 /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = ""; }; 49 | E2CA68044BE6867A7EBF5451 /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = ""; }; 50 | /* End PBXFileReference section */ 51 | 52 | /* Begin PBXFrameworksBuildPhase section */ 53 | 97C146EB1CF9000F007C117D /* Frameworks */ = { 54 | isa = PBXFrameworksBuildPhase; 55 | buildActionMask = 2147483647; 56 | files = ( 57 | 31EB1B16C1FC2FF1E00B4150 /* Pods_Runner.framework in Frameworks */, 58 | ); 59 | runOnlyForDeploymentPostprocessing = 0; 60 | }; 61 | /* End PBXFrameworksBuildPhase section */ 62 | 63 | /* Begin PBXGroup section */ 64 | 1FDB99D1BAFA6B1A3F95B6CC /* Pods */ = { 65 | isa = PBXGroup; 66 | children = ( 67 | E2CA68044BE6867A7EBF5451 /* Pods-Runner.debug.xcconfig */, 68 | 144794647118CA68283DCB5C /* Pods-Runner.release.xcconfig */, 69 | C5903CB79AFF3A14E3193499 /* Pods-Runner.profile.xcconfig */, 70 | ); 71 | path = Pods; 72 | sourceTree = ""; 73 | }; 74 | 3A0113B75112EAC3C7B41AB7 /* Frameworks */ = { 75 | isa = PBXGroup; 76 | children = ( 77 | 1CD7E9ADAA6E473663EAECC8 /* Pods_Runner.framework */, 78 | ); 79 | name = Frameworks; 80 | sourceTree = ""; 81 | }; 82 | 9740EEB11CF90186004384FC /* Flutter */ = { 83 | isa = PBXGroup; 84 | children = ( 85 | 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */, 86 | 9740EEB21CF90195004384FC /* Debug.xcconfig */, 87 | 7AFA3C8E1D35360C0083082E /* Release.xcconfig */, 88 | 9740EEB31CF90195004384FC /* Generated.xcconfig */, 89 | ); 90 | name = Flutter; 91 | sourceTree = ""; 92 | }; 93 | 97C146E51CF9000F007C117D = { 94 | isa = PBXGroup; 95 | children = ( 96 | 9740EEB11CF90186004384FC /* Flutter */, 97 | 97C146F01CF9000F007C117D /* Runner */, 98 | 97C146EF1CF9000F007C117D /* Products */, 99 | 1FDB99D1BAFA6B1A3F95B6CC /* Pods */, 100 | 3A0113B75112EAC3C7B41AB7 /* Frameworks */, 101 | ); 102 | sourceTree = ""; 103 | }; 104 | 97C146EF1CF9000F007C117D /* Products */ = { 105 | isa = PBXGroup; 106 | children = ( 107 | 97C146EE1CF9000F007C117D /* Runner.app */, 108 | ); 109 | name = Products; 110 | sourceTree = ""; 111 | }; 112 | 97C146F01CF9000F007C117D /* Runner */ = { 113 | isa = PBXGroup; 114 | children = ( 115 | 97C146FA1CF9000F007C117D /* Main.storyboard */, 116 | 97C146FD1CF9000F007C117D /* Assets.xcassets */, 117 | 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */, 118 | 97C147021CF9000F007C117D /* Info.plist */, 119 | 97C146F11CF9000F007C117D /* Supporting Files */, 120 | 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */, 121 | 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */, 122 | 74858FAE1ED2DC5600515810 /* AppDelegate.swift */, 123 | 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */, 124 | ); 125 | path = Runner; 126 | sourceTree = ""; 127 | }; 128 | 97C146F11CF9000F007C117D /* Supporting Files */ = { 129 | isa = PBXGroup; 130 | children = ( 131 | ); 132 | name = "Supporting Files"; 133 | sourceTree = ""; 134 | }; 135 | /* End PBXGroup section */ 136 | 137 | /* Begin PBXNativeTarget section */ 138 | 97C146ED1CF9000F007C117D /* Runner */ = { 139 | isa = PBXNativeTarget; 140 | buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */; 141 | buildPhases = ( 142 | 1F36C6A693058B0D41F364F8 /* [CP] Check Pods Manifest.lock */, 143 | 9740EEB61CF901F6004384FC /* Run Script */, 144 | 97C146EA1CF9000F007C117D /* Sources */, 145 | 97C146EB1CF9000F007C117D /* Frameworks */, 146 | 97C146EC1CF9000F007C117D /* Resources */, 147 | 9705A1C41CF9048500538489 /* Embed Frameworks */, 148 | 3B06AD1E1E4923F5004D2608 /* Thin Binary */, 149 | C3C1695C34390AF2055460FB /* [CP] Embed Pods Frameworks */, 150 | ); 151 | buildRules = ( 152 | ); 153 | dependencies = ( 154 | ); 155 | name = Runner; 156 | productName = Runner; 157 | productReference = 97C146EE1CF9000F007C117D /* Runner.app */; 158 | productType = "com.apple.product-type.application"; 159 | }; 160 | /* End PBXNativeTarget section */ 161 | 162 | /* Begin PBXProject section */ 163 | 97C146E61CF9000F007C117D /* Project object */ = { 164 | isa = PBXProject; 165 | attributes = { 166 | LastUpgradeCheck = 1030; 167 | ORGANIZATIONNAME = "The Chromium Authors"; 168 | TargetAttributes = { 169 | 97C146ED1CF9000F007C117D = { 170 | CreatedOnToolsVersion = 7.3.1; 171 | DevelopmentTeam = XXB3A2BN5T; 172 | LastSwiftMigration = 0910; 173 | }; 174 | }; 175 | }; 176 | buildConfigurationList = 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */; 177 | compatibilityVersion = "Xcode 3.2"; 178 | developmentRegion = en; 179 | hasScannedForEncodings = 0; 180 | knownRegions = ( 181 | en, 182 | Base, 183 | ); 184 | mainGroup = 97C146E51CF9000F007C117D; 185 | productRefGroup = 97C146EF1CF9000F007C117D /* Products */; 186 | projectDirPath = ""; 187 | projectRoot = ""; 188 | targets = ( 189 | 97C146ED1CF9000F007C117D /* Runner */, 190 | ); 191 | }; 192 | /* End PBXProject section */ 193 | 194 | /* Begin PBXResourcesBuildPhase section */ 195 | 97C146EC1CF9000F007C117D /* Resources */ = { 196 | isa = PBXResourcesBuildPhase; 197 | buildActionMask = 2147483647; 198 | files = ( 199 | 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */, 200 | 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */, 201 | 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */, 202 | 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */, 203 | ); 204 | runOnlyForDeploymentPostprocessing = 0; 205 | }; 206 | /* End PBXResourcesBuildPhase section */ 207 | 208 | /* Begin PBXShellScriptBuildPhase section */ 209 | 1F36C6A693058B0D41F364F8 /* [CP] Check Pods Manifest.lock */ = { 210 | isa = PBXShellScriptBuildPhase; 211 | buildActionMask = 2147483647; 212 | files = ( 213 | ); 214 | inputFileListPaths = ( 215 | ); 216 | inputPaths = ( 217 | "${PODS_PODFILE_DIR_PATH}/Podfile.lock", 218 | "${PODS_ROOT}/Manifest.lock", 219 | ); 220 | name = "[CP] Check Pods Manifest.lock"; 221 | outputFileListPaths = ( 222 | ); 223 | outputPaths = ( 224 | "$(DERIVED_FILE_DIR)/Pods-Runner-checkManifestLockResult.txt", 225 | ); 226 | runOnlyForDeploymentPostprocessing = 0; 227 | shellPath = /bin/sh; 228 | shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; 229 | showEnvVarsInLog = 0; 230 | }; 231 | 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = { 232 | isa = PBXShellScriptBuildPhase; 233 | buildActionMask = 2147483647; 234 | files = ( 235 | ); 236 | inputPaths = ( 237 | ); 238 | name = "Thin Binary"; 239 | outputPaths = ( 240 | ); 241 | runOnlyForDeploymentPostprocessing = 0; 242 | shellPath = /bin/sh; 243 | shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin"; 244 | }; 245 | 9740EEB61CF901F6004384FC /* Run Script */ = { 246 | isa = PBXShellScriptBuildPhase; 247 | buildActionMask = 2147483647; 248 | files = ( 249 | ); 250 | inputPaths = ( 251 | ); 252 | name = "Run Script"; 253 | outputPaths = ( 254 | ); 255 | runOnlyForDeploymentPostprocessing = 0; 256 | shellPath = /bin/sh; 257 | shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build"; 258 | }; 259 | C3C1695C34390AF2055460FB /* [CP] Embed Pods Frameworks */ = { 260 | isa = PBXShellScriptBuildPhase; 261 | buildActionMask = 2147483647; 262 | files = ( 263 | ); 264 | inputPaths = ( 265 | "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh", 266 | "${PODS_ROOT}/../Flutter/Flutter.framework", 267 | "${BUILT_PRODUCTS_DIR}/audioplayers/audioplayers.framework", 268 | "${BUILT_PRODUCTS_DIR}/path_provider/path_provider.framework", 269 | "${BUILT_PRODUCTS_DIR}/video_player/video_player.framework", 270 | "${BUILT_PRODUCTS_DIR}/wakelock/wakelock.framework", 271 | ); 272 | name = "[CP] Embed Pods Frameworks"; 273 | outputPaths = ( 274 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Flutter.framework", 275 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/audioplayers.framework", 276 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/path_provider.framework", 277 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/video_player.framework", 278 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/wakelock.framework", 279 | ); 280 | runOnlyForDeploymentPostprocessing = 0; 281 | shellPath = /bin/sh; 282 | shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n"; 283 | showEnvVarsInLog = 0; 284 | }; 285 | /* End PBXShellScriptBuildPhase section */ 286 | 287 | /* Begin PBXSourcesBuildPhase section */ 288 | 97C146EA1CF9000F007C117D /* Sources */ = { 289 | isa = PBXSourcesBuildPhase; 290 | buildActionMask = 2147483647; 291 | files = ( 292 | 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */, 293 | 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */, 294 | ); 295 | runOnlyForDeploymentPostprocessing = 0; 296 | }; 297 | /* End PBXSourcesBuildPhase section */ 298 | 299 | /* Begin PBXVariantGroup section */ 300 | 97C146FA1CF9000F007C117D /* Main.storyboard */ = { 301 | isa = PBXVariantGroup; 302 | children = ( 303 | 97C146FB1CF9000F007C117D /* Base */, 304 | ); 305 | name = Main.storyboard; 306 | sourceTree = ""; 307 | }; 308 | 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */ = { 309 | isa = PBXVariantGroup; 310 | children = ( 311 | 97C147001CF9000F007C117D /* Base */, 312 | ); 313 | name = LaunchScreen.storyboard; 314 | sourceTree = ""; 315 | }; 316 | /* End PBXVariantGroup section */ 317 | 318 | /* Begin XCBuildConfiguration section */ 319 | 249021D3217E4FDB00AE95B9 /* Profile */ = { 320 | isa = XCBuildConfiguration; 321 | buildSettings = { 322 | ALWAYS_SEARCH_USER_PATHS = NO; 323 | CLANG_ANALYZER_NONNULL = YES; 324 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 325 | CLANG_CXX_LIBRARY = "libc++"; 326 | CLANG_ENABLE_MODULES = YES; 327 | CLANG_ENABLE_OBJC_ARC = YES; 328 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 329 | CLANG_WARN_BOOL_CONVERSION = YES; 330 | CLANG_WARN_COMMA = YES; 331 | CLANG_WARN_CONSTANT_CONVERSION = YES; 332 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 333 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 334 | CLANG_WARN_EMPTY_BODY = YES; 335 | CLANG_WARN_ENUM_CONVERSION = YES; 336 | CLANG_WARN_INFINITE_RECURSION = YES; 337 | CLANG_WARN_INT_CONVERSION = YES; 338 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 339 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 340 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 341 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 342 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 343 | CLANG_WARN_STRICT_PROTOTYPES = YES; 344 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 345 | CLANG_WARN_UNREACHABLE_CODE = YES; 346 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 347 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 348 | COPY_PHASE_STRIP = NO; 349 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 350 | ENABLE_NS_ASSERTIONS = NO; 351 | ENABLE_STRICT_OBJC_MSGSEND = YES; 352 | GCC_C_LANGUAGE_STANDARD = gnu99; 353 | GCC_NO_COMMON_BLOCKS = YES; 354 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 355 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 356 | GCC_WARN_UNDECLARED_SELECTOR = YES; 357 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 358 | GCC_WARN_UNUSED_FUNCTION = YES; 359 | GCC_WARN_UNUSED_VARIABLE = YES; 360 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 361 | MTL_ENABLE_DEBUG_INFO = NO; 362 | SDKROOT = iphoneos; 363 | TARGETED_DEVICE_FAMILY = "1,2"; 364 | VALIDATE_PRODUCT = YES; 365 | }; 366 | name = Profile; 367 | }; 368 | 249021D4217E4FDB00AE95B9 /* Profile */ = { 369 | isa = XCBuildConfiguration; 370 | baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; 371 | buildSettings = { 372 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 373 | CLANG_ENABLE_MODULES = YES; 374 | CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; 375 | DEVELOPMENT_TEAM = XXB3A2BN5T; 376 | ENABLE_BITCODE = NO; 377 | FRAMEWORK_SEARCH_PATHS = ( 378 | "$(inherited)", 379 | "$(PROJECT_DIR)/Flutter", 380 | ); 381 | INFOPLIST_FILE = Runner/Info.plist; 382 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 383 | LIBRARY_SEARCH_PATHS = ( 384 | "$(inherited)", 385 | "$(PROJECT_DIR)/Flutter", 386 | ); 387 | PRODUCT_BUNDLE_IDENTIFIER = com.example.flutterWidget; 388 | PRODUCT_NAME = "$(TARGET_NAME)"; 389 | SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; 390 | SWIFT_VERSION = 4.0; 391 | VERSIONING_SYSTEM = "apple-generic"; 392 | }; 393 | name = Profile; 394 | }; 395 | 97C147031CF9000F007C117D /* Debug */ = { 396 | isa = XCBuildConfiguration; 397 | buildSettings = { 398 | ALWAYS_SEARCH_USER_PATHS = NO; 399 | CLANG_ANALYZER_NONNULL = YES; 400 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 401 | CLANG_CXX_LIBRARY = "libc++"; 402 | CLANG_ENABLE_MODULES = YES; 403 | CLANG_ENABLE_OBJC_ARC = YES; 404 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 405 | CLANG_WARN_BOOL_CONVERSION = YES; 406 | CLANG_WARN_COMMA = YES; 407 | CLANG_WARN_CONSTANT_CONVERSION = YES; 408 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 409 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 410 | CLANG_WARN_EMPTY_BODY = YES; 411 | CLANG_WARN_ENUM_CONVERSION = YES; 412 | CLANG_WARN_INFINITE_RECURSION = YES; 413 | CLANG_WARN_INT_CONVERSION = YES; 414 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 415 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 416 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 417 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 418 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 419 | CLANG_WARN_STRICT_PROTOTYPES = YES; 420 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 421 | CLANG_WARN_UNREACHABLE_CODE = YES; 422 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 423 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 424 | COPY_PHASE_STRIP = NO; 425 | DEBUG_INFORMATION_FORMAT = dwarf; 426 | ENABLE_STRICT_OBJC_MSGSEND = YES; 427 | ENABLE_TESTABILITY = YES; 428 | GCC_C_LANGUAGE_STANDARD = gnu99; 429 | GCC_DYNAMIC_NO_PIC = NO; 430 | GCC_NO_COMMON_BLOCKS = YES; 431 | GCC_OPTIMIZATION_LEVEL = 0; 432 | GCC_PREPROCESSOR_DEFINITIONS = ( 433 | "DEBUG=1", 434 | "$(inherited)", 435 | ); 436 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 437 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 438 | GCC_WARN_UNDECLARED_SELECTOR = YES; 439 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 440 | GCC_WARN_UNUSED_FUNCTION = YES; 441 | GCC_WARN_UNUSED_VARIABLE = YES; 442 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 443 | MTL_ENABLE_DEBUG_INFO = YES; 444 | ONLY_ACTIVE_ARCH = YES; 445 | SDKROOT = iphoneos; 446 | TARGETED_DEVICE_FAMILY = "1,2"; 447 | }; 448 | name = Debug; 449 | }; 450 | 97C147041CF9000F007C117D /* Release */ = { 451 | isa = XCBuildConfiguration; 452 | buildSettings = { 453 | ALWAYS_SEARCH_USER_PATHS = NO; 454 | CLANG_ANALYZER_NONNULL = YES; 455 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 456 | CLANG_CXX_LIBRARY = "libc++"; 457 | CLANG_ENABLE_MODULES = YES; 458 | CLANG_ENABLE_OBJC_ARC = YES; 459 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 460 | CLANG_WARN_BOOL_CONVERSION = YES; 461 | CLANG_WARN_COMMA = YES; 462 | CLANG_WARN_CONSTANT_CONVERSION = YES; 463 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 464 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 465 | CLANG_WARN_EMPTY_BODY = YES; 466 | CLANG_WARN_ENUM_CONVERSION = YES; 467 | CLANG_WARN_INFINITE_RECURSION = YES; 468 | CLANG_WARN_INT_CONVERSION = YES; 469 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 470 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 471 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 472 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 473 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 474 | CLANG_WARN_STRICT_PROTOTYPES = YES; 475 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 476 | CLANG_WARN_UNREACHABLE_CODE = YES; 477 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 478 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 479 | COPY_PHASE_STRIP = NO; 480 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 481 | ENABLE_NS_ASSERTIONS = NO; 482 | ENABLE_STRICT_OBJC_MSGSEND = YES; 483 | GCC_C_LANGUAGE_STANDARD = gnu99; 484 | GCC_NO_COMMON_BLOCKS = YES; 485 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 486 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 487 | GCC_WARN_UNDECLARED_SELECTOR = YES; 488 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 489 | GCC_WARN_UNUSED_FUNCTION = YES; 490 | GCC_WARN_UNUSED_VARIABLE = YES; 491 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 492 | MTL_ENABLE_DEBUG_INFO = NO; 493 | SDKROOT = iphoneos; 494 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 495 | TARGETED_DEVICE_FAMILY = "1,2"; 496 | VALIDATE_PRODUCT = YES; 497 | }; 498 | name = Release; 499 | }; 500 | 97C147061CF9000F007C117D /* Debug */ = { 501 | isa = XCBuildConfiguration; 502 | baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; 503 | buildSettings = { 504 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 505 | CLANG_ENABLE_MODULES = YES; 506 | CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; 507 | DEVELOPMENT_TEAM = XXB3A2BN5T; 508 | ENABLE_BITCODE = NO; 509 | FRAMEWORK_SEARCH_PATHS = ( 510 | "$(inherited)", 511 | "$(PROJECT_DIR)/Flutter", 512 | ); 513 | INFOPLIST_FILE = Runner/Info.plist; 514 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 515 | LIBRARY_SEARCH_PATHS = ( 516 | "$(inherited)", 517 | "$(PROJECT_DIR)/Flutter", 518 | ); 519 | PRODUCT_BUNDLE_IDENTIFIER = com.example.flutterWidget; 520 | PRODUCT_NAME = "$(TARGET_NAME)"; 521 | SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; 522 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 523 | SWIFT_VERSION = 4.0; 524 | VERSIONING_SYSTEM = "apple-generic"; 525 | }; 526 | name = Debug; 527 | }; 528 | 97C147071CF9000F007C117D /* Release */ = { 529 | isa = XCBuildConfiguration; 530 | baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; 531 | buildSettings = { 532 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 533 | CLANG_ENABLE_MODULES = YES; 534 | CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; 535 | DEVELOPMENT_TEAM = XXB3A2BN5T; 536 | ENABLE_BITCODE = NO; 537 | FRAMEWORK_SEARCH_PATHS = ( 538 | "$(inherited)", 539 | "$(PROJECT_DIR)/Flutter", 540 | ); 541 | INFOPLIST_FILE = Runner/Info.plist; 542 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 543 | LIBRARY_SEARCH_PATHS = ( 544 | "$(inherited)", 545 | "$(PROJECT_DIR)/Flutter", 546 | ); 547 | PRODUCT_BUNDLE_IDENTIFIER = com.example.flutterWidget; 548 | PRODUCT_NAME = "$(TARGET_NAME)"; 549 | SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; 550 | SWIFT_VERSION = 4.0; 551 | VERSIONING_SYSTEM = "apple-generic"; 552 | }; 553 | name = Release; 554 | }; 555 | /* End XCBuildConfiguration section */ 556 | 557 | /* Begin XCConfigurationList section */ 558 | 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */ = { 559 | isa = XCConfigurationList; 560 | buildConfigurations = ( 561 | 97C147031CF9000F007C117D /* Debug */, 562 | 97C147041CF9000F007C117D /* Release */, 563 | 249021D3217E4FDB00AE95B9 /* Profile */, 564 | ); 565 | defaultConfigurationIsVisible = 0; 566 | defaultConfigurationName = Release; 567 | }; 568 | 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */ = { 569 | isa = XCConfigurationList; 570 | buildConfigurations = ( 571 | 97C147061CF9000F007C117D /* Debug */, 572 | 97C147071CF9000F007C117D /* Release */, 573 | 249021D4217E4FDB00AE95B9 /* Profile */, 574 | ); 575 | defaultConfigurationIsVisible = 0; 576 | defaultConfigurationName = Release; 577 | }; 578 | /* End XCConfigurationList section */ 579 | }; 580 | rootObject = 97C146E61CF9000F007C117D /* Project object */; 581 | } 582 | -------------------------------------------------------------------------------- /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/xcshareddata/xcschemes/Runner.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 43 | 44 | 54 | 56 | 62 | 63 | 64 | 65 | 66 | 67 | 73 | 75 | 81 | 82 | 83 | 84 | 86 | 87 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /ios/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /ios/Runner/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // Runner 4 | // 5 | // Created by 阿明 on 2019/10/25. 6 | // Copyright © 2019 The Chromium Authors. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | @interface AppDelegate : NSObject 14 | 15 | @end 16 | 17 | NS_ASSUME_NONNULL_END 18 | -------------------------------------------------------------------------------- /ios/Runner/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // Runner 4 | // 5 | // Created by 阿明 on 2019/10/25. 6 | // Copyright © 2019 The Chromium Authors. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @implementation AppDelegate 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /ios/Runner/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | import UIKit 5 | import Flutter 6 | 7 | enum ChannelName { 8 | static let battery = "samples.flutter.io/battery" 9 | static let charging = "samples.flutter.io/charging" 10 | } 11 | 12 | enum BatteryState { 13 | static let charging = "charging" 14 | static let discharging = "discharging" 15 | } 16 | 17 | enum MyFlutterErrorCode { 18 | static let unavailable = "UNAVAILABLE" 19 | } 20 | 21 | @UIApplicationMain 22 | @objc class AppDelegate: FlutterAppDelegate, FlutterStreamHandler { 23 | private var eventSink: FlutterEventSink? 24 | 25 | override func application( 26 | _ application: UIApplication, 27 | didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { 28 | GeneratedPluginRegistrant.register(with: self) 29 | guard let controller = window?.rootViewController as? FlutterViewController else { 30 | fatalError("rootViewController is not type FlutterViewController") 31 | } 32 | let batteryChannel = FlutterMethodChannel(name: ChannelName.battery, 33 | binaryMessenger: controller.binaryMessenger) 34 | batteryChannel.setMethodCallHandler({ 35 | [weak self] (call: FlutterMethodCall, result: FlutterResult) -> Void in 36 | guard call.method == "getBatteryLevel" else { 37 | result(FlutterMethodNotImplemented) 38 | return 39 | } 40 | self?.receiveBatteryLevel(result: result) 41 | }) 42 | 43 | let chargingChannel = FlutterEventChannel(name: ChannelName.charging, 44 | binaryMessenger: controller.binaryMessenger) 45 | chargingChannel.setStreamHandler(self) 46 | return super.application(application, didFinishLaunchingWithOptions: launchOptions) 47 | } 48 | 49 | private func receiveBatteryLevel(result: FlutterResult) { 50 | let device = UIDevice.current 51 | device.isBatteryMonitoringEnabled = true 52 | guard device.batteryState != .unknown else { 53 | result(FlutterError(code: MyFlutterErrorCode.unavailable, 54 | message: "Battery info unavailable", 55 | details: nil)) 56 | return 57 | } 58 | result(Int(device.batteryLevel * 100)) 59 | } 60 | 61 | public func onListen(withArguments arguments: Any?, 62 | eventSink: @escaping FlutterEventSink) -> FlutterError? { 63 | self.eventSink = eventSink 64 | UIDevice.current.isBatteryMonitoringEnabled = true 65 | sendBatteryStateEvent() 66 | NotificationCenter.default.addObserver( 67 | self, 68 | selector: #selector(AppDelegate.onBatteryStateDidChange), 69 | name: NSNotification.Name.UIDeviceBatteryStateDidChange, 70 | object: nil) 71 | return nil 72 | } 73 | 74 | @objc private func onBatteryStateDidChange(notification: NSNotification) { 75 | sendBatteryStateEvent() 76 | } 77 | 78 | private func sendBatteryStateEvent() { 79 | guard let eventSink = eventSink else { 80 | return 81 | } 82 | 83 | switch UIDevice.current.batteryState { 84 | case .full: 85 | eventSink(BatteryState.charging) 86 | case .charging: 87 | eventSink(BatteryState.charging) 88 | case .unplugged: 89 | eventSink(BatteryState.discharging) 90 | default: 91 | eventSink(FlutterError(code: MyFlutterErrorCode.unavailable, 92 | message: "Charging status unavailable", 93 | details: nil)) 94 | } 95 | } 96 | 97 | public func onCancel(withArguments arguments: Any?) -> FlutterError? { 98 | NotificationCenter.default.removeObserver(self) 99 | eventSink = nil 100 | return nil 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "20x20", 5 | "idiom" : "iphone", 6 | "filename" : "Icon-App-20x20@2x.png", 7 | "scale" : "2x" 8 | }, 9 | { 10 | "size" : "20x20", 11 | "idiom" : "iphone", 12 | "filename" : "Icon-App-20x20@3x.png", 13 | "scale" : "3x" 14 | }, 15 | { 16 | "size" : "29x29", 17 | "idiom" : "iphone", 18 | "filename" : "Icon-App-29x29@1x.png", 19 | "scale" : "1x" 20 | }, 21 | { 22 | "size" : "29x29", 23 | "idiom" : "iphone", 24 | "filename" : "Icon-App-29x29@2x.png", 25 | "scale" : "2x" 26 | }, 27 | { 28 | "size" : "29x29", 29 | "idiom" : "iphone", 30 | "filename" : "Icon-App-29x29@3x.png", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "size" : "40x40", 35 | "idiom" : "iphone", 36 | "filename" : "Icon-App-40x40@2x.png", 37 | "scale" : "2x" 38 | }, 39 | { 40 | "size" : "40x40", 41 | "idiom" : "iphone", 42 | "filename" : "Icon-App-40x40@3x.png", 43 | "scale" : "3x" 44 | }, 45 | { 46 | "size" : "60x60", 47 | "idiom" : "iphone", 48 | "filename" : "Icon-App-60x60@2x.png", 49 | "scale" : "2x" 50 | }, 51 | { 52 | "size" : "60x60", 53 | "idiom" : "iphone", 54 | "filename" : "Icon-App-60x60@3x.png", 55 | "scale" : "3x" 56 | }, 57 | { 58 | "size" : "20x20", 59 | "idiom" : "ipad", 60 | "filename" : "Icon-App-20x20@1x.png", 61 | "scale" : "1x" 62 | }, 63 | { 64 | "size" : "20x20", 65 | "idiom" : "ipad", 66 | "filename" : "Icon-App-20x20@2x.png", 67 | "scale" : "2x" 68 | }, 69 | { 70 | "size" : "29x29", 71 | "idiom" : "ipad", 72 | "filename" : "Icon-App-29x29@1x.png", 73 | "scale" : "1x" 74 | }, 75 | { 76 | "size" : "29x29", 77 | "idiom" : "ipad", 78 | "filename" : "Icon-App-29x29@2x.png", 79 | "scale" : "2x" 80 | }, 81 | { 82 | "size" : "40x40", 83 | "idiom" : "ipad", 84 | "filename" : "Icon-App-40x40@1x.png", 85 | "scale" : "1x" 86 | }, 87 | { 88 | "size" : "40x40", 89 | "idiom" : "ipad", 90 | "filename" : "Icon-App-40x40@2x.png", 91 | "scale" : "2x" 92 | }, 93 | { 94 | "size" : "76x76", 95 | "idiom" : "ipad", 96 | "filename" : "Icon-App-76x76@1x.png", 97 | "scale" : "1x" 98 | }, 99 | { 100 | "size" : "76x76", 101 | "idiom" : "ipad", 102 | "filename" : "Icon-App-76x76@2x.png", 103 | "scale" : "2x" 104 | }, 105 | { 106 | "size" : "83.5x83.5", 107 | "idiom" : "ipad", 108 | "filename" : "Icon-App-83.5x83.5@2x.png", 109 | "scale" : "2x" 110 | }, 111 | { 112 | "size" : "1024x1024", 113 | "idiom" : "ios-marketing", 114 | "filename" : "Icon-App-1024x1024@1x.png", 115 | "scale" : "1x" 116 | } 117 | ], 118 | "info" : { 119 | "version" : 1, 120 | "author" : "xcode" 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tecode/flutter_widget/3a22898c58114bd942162ca1fc7bbdcef9396430/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/Tecode/flutter_widget/3a22898c58114bd942162ca1fc7bbdcef9396430/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/Tecode/flutter_widget/3a22898c58114bd942162ca1fc7bbdcef9396430/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/Tecode/flutter_widget/3a22898c58114bd942162ca1fc7bbdcef9396430/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/Tecode/flutter_widget/3a22898c58114bd942162ca1fc7bbdcef9396430/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/Tecode/flutter_widget/3a22898c58114bd942162ca1fc7bbdcef9396430/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/Tecode/flutter_widget/3a22898c58114bd942162ca1fc7bbdcef9396430/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/Tecode/flutter_widget/3a22898c58114bd942162ca1fc7bbdcef9396430/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/Tecode/flutter_widget/3a22898c58114bd942162ca1fc7bbdcef9396430/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/Tecode/flutter_widget/3a22898c58114bd942162ca1fc7bbdcef9396430/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/Tecode/flutter_widget/3a22898c58114bd942162ca1fc7bbdcef9396430/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/Tecode/flutter_widget/3a22898c58114bd942162ca1fc7bbdcef9396430/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/Tecode/flutter_widget/3a22898c58114bd942162ca1fc7bbdcef9396430/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/Tecode/flutter_widget/3a22898c58114bd942162ca1fc7bbdcef9396430/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/Tecode/flutter_widget/3a22898c58114bd942162ca1fc7bbdcef9396430/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/Tecode/flutter_widget/3a22898c58114bd942162ca1fc7bbdcef9396430/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tecode/flutter_widget/3a22898c58114bd942162ca1fc7bbdcef9396430/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tecode/flutter_widget/3a22898c58114bd942162ca1fc7bbdcef9396430/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/AudioplayerPlugin.h: -------------------------------------------------------------------------------- 1 | // 2 | // AudioplayerPlugin.h 3 | // Runner 4 | // 5 | // Created by 阿明 on 2019/10/25. 6 | // Copyright © 2019 The Chromium Authors. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | @interface AudioplayerPlugin : NSObject 14 | 15 | @end 16 | 17 | NS_ASSUME_NONNULL_END 18 | -------------------------------------------------------------------------------- /ios/Runner/AudioplayerPlugin.m: -------------------------------------------------------------------------------- 1 | // 2 | // AudioplayerPlugin.m 3 | // Runner 4 | // 5 | // Created by 阿明 on 2019/10/25. 6 | // Copyright © 2019 The Chromium Authors. All rights reserved. 7 | // 8 | 9 | #import "AudioplayerPlugin.h" 10 | 11 | @implementation AudioplayerPlugin 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /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/ConfigurationHelper.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ConfigurationHelper.swift 3 | // BrainScientist_Business 4 | // 5 | // Created by 沈鑫 on 2019/3/19. 6 | // Copyright © 2019 BrainScientist. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import IQKeyboardManagerSwift 11 | import AVFoundation 12 | import Kingfisher 13 | 14 | let sdkAppid = 1400194089 15 | let sdkAccountType = "36862" 16 | let identifier = "krcm110" 17 | let userSig = "eJxlj11PgzAYhe-5FaTXRltKNzHZxaZuUTcMMCTuhhTaSkPooBT8iv-diBqb*N4*T84577vjui7Yb5NTWpbHQZncvLYcuBcugODkD7atZDk1OdbsH*QvrdQ8p8JwPUFECPEgtB3JuDJSyB*j1mWDkC30rM6nlu8EH0IU*PA8sBX5NMHddXR5sxlnWX3ISpEqL0RXfkIaWg1VWse3VTEcYpEGKuzul2cP66VcZWPbNX0x6m2UvXVRHG7kKiRire7i5wbvkseC0XlVp-0*WiysSiMb-vsSxnBOZvagketeHtUkeBAR5GH4dcD5cD4BFpdeiA__" 18 | /** 高德地图appkey*/ 19 | let mapApiKey = "5e9242e82a4c9bf3951cc6f1f33a3287" 20 | let JPUSH_APPKEY = "1e276f53606380ff031e22ed" 21 | let channelKey = "BrainScientist-iOS"; 22 | 23 | class ConfigurationHelper: NSObject, WXApiDelegate { 24 | 25 | var shareHandler: (( _ resp: BaseResp) -> Void)? 26 | 27 | /** 单例*/ 28 | static let shared = ConfigurationHelper() 29 | 30 | class func initializeConfiguration() { 31 | self.networkChange() 32 | self.userInterfaceConfiguration() 33 | // self.keyboardManagerConfiguration() 34 | VersionRefreshHelper.shared.logout() 35 | self.progressHUDConfiguration() 36 | self.ShareSDKConfiguration() 37 | self.TIMConfiguration() 38 | self.AMapServicesConfiguration() 39 | self.BuglyConfiguration() 40 | if !VersionRefreshHelper.shared.isGoingAppFrist { 41 | VersionRefreshHelper.shared.isGoingAppFrist = true 42 | } else { 43 | if !self.isUserNotificationEnable() { 44 | SystemAler.shared.show("“脑学家”想给您发送通知", "您的手机需要开启通知权限之后才能正常接收通知。", ["取消","去设置"]) { (index) in 45 | if index == 0 { 46 | 47 | } else { 48 | self.goToAppSystemSetting() 49 | } 50 | } 51 | } 52 | } 53 | } 54 | 55 | class func resetRoot() -> UIViewController { 56 | if UserInfoHelper.shared.addNickname { 57 | let nicknameVC = LoginChangeNickNameViewController(nibName: "LoginChangeNickNameViewController", bundle: nil) 58 | nicknameVC.businessUser = UserInfoHelper.shared.businessUser 59 | let rootNav = BaseNavigationController.init(rootViewController: nicknameVC) 60 | rootNav.navigationBar.isHidden = true 61 | return rootNav 62 | } else { 63 | if UserInfoHelper.shared.isLogin { 64 | let rootNav = BaseNavigationController.init(rootViewController: RootTabBarController()) 65 | rootNav.navigationBar.isHidden = true 66 | return rootNav 67 | } else { 68 | let loginNav = BaseNavigationController.init(rootViewController: LoginViewController.init(nibName: "LoginViewController", bundle: nil)) 69 | loginNav.navigationBar.isHidden = true 70 | return loginNav 71 | } 72 | } 73 | } 74 | 75 | /** 判断用户是否允许接受通知消息*/ 76 | class func isUserNotificationEnable() -> Bool { 77 | var isEnable: Bool = false 78 | let setting = UIApplication.shared.currentUserNotificationSettings 79 | isEnable = (UIUserNotificationType.init(rawValue: 0) == setting!.types) ? false : true 80 | return isEnable 81 | } 82 | //MARK: 跳转到设置页面 83 | class func goToAppSystemSetting() { 84 | let application = UIApplication.shared 85 | let url = URL.init(string: UIApplication.openSettingsURLString) 86 | if application.canOpenURL(url!) { 87 | if #available(iOS 10.0, *) { 88 | application.open(url!, options: [:], completionHandler: nil) 89 | } else { 90 | // Fallback on earlier versions 91 | application.openURL(url!) 92 | } 93 | } 94 | } 95 | 96 | class func JPUSHConfiguration(_ application: UIApplication, launchOptions: [UIApplication.LaunchOptionsKey: Any]?, delegate: JPUSHRegisterDelegate) { 97 | 98 | let entity = JPUSHRegisterEntity() 99 | if #available(iOS 12.0, *) { 100 | entity.types = Int(JPAuthorizationOptions.alert.rawValue|JPAuthorizationOptions.badge.rawValue|JPAuthorizationOptions.sound.rawValue|JPAuthorizationOptions.providesAppNotificationSettings.rawValue) 101 | } else { 102 | // Fallback on earlier versions 103 | } 104 | JPUSHService.registrationIDCompletionHandler { (retCode, registrationID) in 105 | if retCode == 0 { 106 | USERDEFAULTS.set(registrationID, forKey: "registrationID") 107 | USERDEFAULTS.synchronize() 108 | } else { 109 | USERDEFAULTS.set("", forKey: "registrationID") 110 | USERDEFAULTS.synchronize() 111 | } 112 | 113 | if #available(iOS 10.0, *) { 114 | let center = UNUserNotificationCenter.current() 115 | center.requestAuthorization(options: (UNAuthorizationOptions(rawValue: UNAuthorizationOptions.alert.rawValue + UNAuthorizationOptions.sound.rawValue)), completionHandler: { (granted, error) in 116 | 117 | }) 118 | } else { 119 | let settings = UIUserNotificationSettings.init(types: .badge, categories: nil) 120 | UIApplication.shared.registerUserNotificationSettings(settings) 121 | application.registerForRemoteNotifications() 122 | } 123 | } 124 | JPUSHService.register(forRemoteNotificationConfig: entity, delegate: delegate) 125 | JPUSHService.setup(withOption: launchOptions, appKey: JPUSH_APPKEY, channel: channelKey, apsForProduction: false) 126 | } 127 | 128 | private class func BuglyConfiguration() { 129 | Bugly.start(withAppId: "d1e2f2b658") 130 | } 131 | 132 | /** 设置UITabBarItem属性*/ 133 | private class func userInterfaceConfiguration() { 134 | UIBarButtonItem.appearance().setTitleTextAttributes([NSAttributedString.Key.foregroundColor : UIColor.red], for: .normal) 135 | UIBarButtonItem.appearance().setTitleTextAttributes([NSAttributedString.Key.foregroundColor : UIColor.red], for: .selected) 136 | } 137 | 138 | /** 设置IQKeyboardManager*/ 139 | private class func keyboardManagerConfiguration() { 140 | IQKeyboardManager.shared.enable = true 141 | IQKeyboardManager.shared.enableAutoToolbar = false 142 | IQKeyboardManager.shared.shouldResignOnTouchOutside = false 143 | } 144 | 145 | /** 设置SVProgressHUD*/ 146 | private class func progressHUDConfiguration() { 147 | } 148 | 149 | /** shareSDK*/ 150 | private class func ShareSDKConfiguration() { 151 | WXApi.registerApp("wx5e7cbffb0621d349") 152 | } 153 | 154 | class func wxHandleOpenURL(url: URL) -> Bool { 155 | return WXApi.handleOpen(url, delegate: ConfigurationHelper.shared) 156 | } 157 | 158 | /** 清除缓存*/ 159 | class func cleanCache() { 160 | SDImageCache.shared.clearDisk(onCompletion: nil) 161 | SDImageCache.shared.clearMemory() 162 | KingfisherManager.shared.cache.clearDiskCache() 163 | KingfisherManager.shared.cache.clearMemoryCache() 164 | KingfisherManager.shared.cache.cleanExpiredDiskCache() 165 | } 166 | 167 | /** 计算缓存大小*/ 168 | class func cacheCountData() -> String { 169 | let imageCache: CGFloat = CGFloat(KingfisherManager.shared.cache.maxDiskCacheSize / (1024*1024)) 170 | let sdImageCache: CGFloat = CGFloat(SDImageCache.shared.totalDiskSize() / (1024*1024)) 171 | return String.init(format: "%.1lfMB", imageCache+sdImageCache) 172 | } 173 | 174 | 175 | 176 | private class func AMapServicesConfiguration() { 177 | AMapServices.shared()?.apiKey = mapApiKey 178 | } 179 | 180 | private class func TIMConfiguration() { 181 | TUIKit.sharedInstance()?.setup(withAppId: sdkAppid) 182 | } 183 | 184 | private class func networkChange(){ 185 | RequestHelper.startListening { (status) in 186 | if (status == NetworkStatus.unknown || status == NetworkStatus.notReachable) { 187 | YJYHUD.show("亲,似乎已断开互联网链接!") 188 | } 189 | } 190 | } 191 | 192 | /** WXApiDelegate*/ 193 | func onResp(_ resp: BaseResp) { 194 | if self.shareHandler != nil { 195 | self.shareHandler!(resp) 196 | } 197 | } 198 | } 199 | 200 | -------------------------------------------------------------------------------- /ios/Runner/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | flutter_widget 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | $(FLUTTER_BUILD_NAME) 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | $(FLUTTER_BUILD_NUMBER) 23 | LSRequiresIPhoneOS 24 | 25 | UIBackgroundModes 26 | 27 | audio 28 | 29 | UILaunchStoryboardName 30 | LaunchScreen 31 | UIMainStoryboardFile 32 | Main 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | UISupportedInterfaceOrientations~ipad 40 | 41 | UIInterfaceOrientationPortrait 42 | UIInterfaceOrientationPortraitUpsideDown 43 | UIInterfaceOrientationLandscapeLeft 44 | UIInterfaceOrientationLandscapeRight 45 | 46 | UIViewControllerBasedStatusBarAppearance 47 | 48 | NSAppTransportSecurity 49 | 50 | NSAllowsArbitraryLoads 51 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /ios/Runner/Runner-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | #import "GeneratedPluginRegistrant.h" 2 | -------------------------------------------------------------------------------- /ios/Runner/Runner.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | aps-environment 6 | development 7 | 8 | 9 | -------------------------------------------------------------------------------- /lib/flutterApp.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_widget/routers/AppLifecycleListen.dart'; 3 | import 'package:flutter_widget/routers/CollapseNavigation.dart'; 4 | import 'package:flutter_widget/routers/LoginVideo.dart'; 5 | import 'package:flutter_widget/routers/StackNavBar.dart'; 6 | import 'package:flutter_widget/routers/Swiper.dart'; 7 | import 'package:flutter_widget/routers/UnlimitedHighCarousel.dart'; 8 | import 'package:flutter_widget/routers/AudioApp.dart'; 9 | import 'package:flutter_widget/routers/SlideDown.dart'; 10 | import 'package:flutter_widget/routers/TabBarFixed.dart'; 11 | import 'package:flutter_widget/routers/StickTab.dart'; 12 | import 'package:flutter_widget/routers/PlatformChannel.dart'; 13 | import 'package:flutter_widget/routers/Animationted.dart'; 14 | import 'package:flutter_widget/routers/VideoPictureInPicture.dart'; 15 | import 'package:flutter_widget/routers/carousel_zoom.dart'; 16 | import 'package:flutter_widget/routers/fold_list.dart'; 17 | 18 | class FlutterApp extends StatelessWidget { 19 | @override 20 | Widget build(BuildContext context) { 21 | return Scaffold( 22 | body: SafeArea( 23 | child: Container( 24 | color: Color(0xfffafafa), 25 | padding: EdgeInsets.only(top: 28.0), 26 | child: ListView( 27 | children: [ 28 | ListTile( 29 | title: Text("视频背景登录"), 30 | trailing: Icon( 31 | Icons.keyboard_arrow_right, 32 | color: Colors.black, 33 | ), 34 | onTap: () { 35 | Navigator.push( 36 | context, 37 | MaterialPageRoute( 38 | builder: (context) => const LoginVideo())); 39 | }, 40 | ), 41 | ListTile( 42 | title: Text("具有缩放效果的轮播图"), 43 | trailing: Icon( 44 | Icons.keyboard_arrow_right, 45 | color: Colors.black, 46 | ), 47 | onTap: () { 48 | Navigator.push( 49 | context, 50 | MaterialPageRoute( 51 | builder: (context) => const CarouselZoom())); 52 | }, 53 | ), 54 | ListTile( 55 | title: Text("仿马蜂窝不限高轮播图"), 56 | trailing: Icon( 57 | Icons.keyboard_arrow_right, 58 | color: Colors.black, 59 | ), 60 | onTap: () { 61 | Navigator.push( 62 | context, 63 | MaterialPageRoute( 64 | builder: (context) => const UnlimitedHighCarousel())); 65 | }, 66 | ), 67 | ListTile( 68 | title: Text("下拉菜单"), 69 | trailing: Icon( 70 | Icons.keyboard_arrow_right, 71 | color: Colors.black, 72 | ), 73 | onTap: () { 74 | Navigator.push(context, 75 | MaterialPageRoute(builder: (context) => const SlideDown())); 76 | }, 77 | ), 78 | ListTile( 79 | title: Text("音频播放"), 80 | trailing: Icon( 81 | Icons.keyboard_arrow_right, 82 | color: Colors.black, 83 | ), 84 | onTap: () { 85 | Navigator.push(context, 86 | MaterialPageRoute(builder: (context) => const AudioApp())); 87 | }, 88 | ), 89 | ListTile( 90 | title: Text("固定TabBar"), 91 | trailing: Icon( 92 | Icons.keyboard_arrow_right, 93 | color: Colors.black, 94 | ), 95 | onTap: () { 96 | Navigator.push(context, 97 | MaterialPageRoute(builder: (context) => TabBarFixed())); 98 | }, 99 | ), 100 | ListTile( 101 | title: Text("ListView嵌套ListView"), 102 | trailing: Icon( 103 | Icons.keyboard_arrow_right, 104 | color: Colors.black, 105 | ), 106 | onTap: () { 107 | Navigator.push(context, 108 | MaterialPageRoute(builder: (context) => StickTab())); 109 | }, 110 | ), 111 | ListTile( 112 | title: Text("平台通道"), 113 | trailing: Icon( 114 | Icons.keyboard_arrow_right, 115 | color: Colors.black, 116 | ), 117 | onTap: () { 118 | Navigator.push(context, 119 | MaterialPageRoute(builder: (context) => PlatformChannel())); 120 | }, 121 | ), 122 | ListTile( 123 | title: Text("动画"), 124 | trailing: Icon( 125 | Icons.keyboard_arrow_right, 126 | color: Colors.black, 127 | ), 128 | onTap: () { 129 | Navigator.push(context, 130 | MaterialPageRoute(builder: (context) => Animationted())); 131 | }, 132 | ), 133 | ListTile( 134 | title: Text("Swipe"), 135 | trailing: Icon( 136 | Icons.keyboard_arrow_right, 137 | color: Colors.black, 138 | ), 139 | onTap: () { 140 | Navigator.push( 141 | context, MaterialPageRoute(builder: (context) => Swipe())); 142 | }, 143 | ), 144 | ListTile( 145 | title: Text("滑动导航变色"), 146 | trailing: Icon( 147 | Icons.keyboard_arrow_right, 148 | color: Colors.black, 149 | ), 150 | onTap: () { 151 | Navigator.push(context, 152 | MaterialPageRoute(builder: (context) => StackNavBar())); 153 | }, 154 | ), 155 | ListTile( 156 | title: Text("滑动隐藏导航"), 157 | trailing: Icon( 158 | Icons.keyboard_arrow_right, 159 | color: Colors.black, 160 | ), 161 | onTap: () { 162 | Navigator.push( 163 | context, 164 | MaterialPageRoute( 165 | builder: (context) => CollapseNavigation())); 166 | }, 167 | ), 168 | ListTile( 169 | title: Text("App状态监听"), 170 | trailing: Icon( 171 | Icons.keyboard_arrow_right, 172 | color: Colors.black, 173 | ), 174 | onTap: () { 175 | Navigator.push( 176 | context, 177 | MaterialPageRoute( 178 | builder: (context) => AppLifecycleListen())); 179 | }, 180 | ), 181 | ListTile( 182 | title: Text("视频嵌套播放"), 183 | trailing: Icon( 184 | Icons.keyboard_arrow_right, 185 | color: Colors.black, 186 | ), 187 | onTap: () { 188 | Navigator.push( 189 | context, 190 | MaterialPageRoute( 191 | builder: (context) => VideoPictureInPicture())); 192 | }, 193 | ), 194 | ListTile( 195 | title: Text("折叠列表"), 196 | trailing: Icon( 197 | Icons.keyboard_arrow_right, 198 | color: Colors.black, 199 | ), 200 | onTap: () { 201 | Navigator.push(context, 202 | MaterialPageRoute(builder: (context) => FoldList())); 203 | }, 204 | ), 205 | ], 206 | ), 207 | ), 208 | )); 209 | } 210 | } 211 | -------------------------------------------------------------------------------- /lib/helpers/audio.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | 3 | import 'package:flutter/services.dart'; 4 | 5 | /// Communicates the current state of the audio player. 6 | enum AudioPlayerState { 7 | /// Player is stopped. No file is loaded to the player. Calling [resume] or 8 | /// [pause] will result in exception. 9 | STOPPED, 10 | /// Currently playing a file. The user can [pause], [resume] or [stop] the 11 | /// playback. 12 | PLAYING, 13 | /// Paused. The user can [resume] the playback without providing the URL. 14 | PAUSED, 15 | /// The playback has been completed. This state is the same as [STOPPED], 16 | /// however we differentiate it because some clients might want to know when 17 | /// the playback is done versus when the user has stopped the playback. 18 | COMPLETED, 19 | } 20 | 21 | const MethodChannel _channel = 22 | const MethodChannel('bz.rxla.flutter/audio'); 23 | 24 | /// A plugin for controlling the on device audio player. 25 | /// 26 | /// Due to the async nature of the native APIs, this plugin delegates all control 27 | /// methods to native without informing the caller of the state changes that happen 28 | /// as a result of these calls. The state changes are communicated via the 29 | /// [onPlayerStateChanged] stream instead so clients are expected to subscribe 30 | /// to this. 31 | class AudioPlayer { 32 | final StreamController _playerStateController = 33 | new StreamController.broadcast(); 34 | 35 | final StreamController _positionController = 36 | new StreamController.broadcast(); 37 | 38 | AudioPlayerState _state = AudioPlayerState.STOPPED; 39 | Duration _duration = const Duration(); 40 | 41 | AudioPlayer() { 42 | _channel.setMethodCallHandler(_audioPlayerStateChange); 43 | } 44 | 45 | /// Play a given url. 46 | Future play(String url, {bool isLocal: false}) async => 47 | await _channel.invokeMethod('play', {'url': url, 'isLocal': isLocal}); 48 | 49 | /// Pause the currently playing stream. 50 | Future pause() async => await _channel.invokeMethod('pause'); 51 | 52 | /// Stop the currently playing stream. 53 | Future stop() async => await _channel.invokeMethod('stop'); 54 | 55 | /// Mute sound. 56 | Future mute(bool muted) async => await _channel.invokeMethod('mute', muted); 57 | 58 | /// Seek to a specific position in the audio stream. 59 | Future seek(double seconds) async => await _channel.invokeMethod('seek', seconds); 60 | 61 | /// Stream for subscribing to player state change events. 62 | Stream get onPlayerStateChanged => _playerStateController.stream; 63 | 64 | /// Reports what the player is currently doing. 65 | AudioPlayerState get state => _state; 66 | 67 | /// Reports the duration of the current media being played. It might return 68 | /// 0 if we have not determined the length of the media yet. It is best to 69 | /// call this from a state listener when the state has become 70 | /// [AudioPlayerState.PLAYING]. 71 | Duration get duration => _duration; 72 | 73 | /// Stream for subscribing to audio position change events. Roughly fires 74 | /// every 200 milliseconds. Will continously update the position of the 75 | /// playback if the status is [AudioPlayerState.PLAYING]. 76 | Stream get onAudioPositionChanged => _positionController.stream; 77 | 78 | Future _audioPlayerStateChange(MethodCall call) async { 79 | switch (call.method) { 80 | case "audio.onCurrentPosition": 81 | assert(_state == AudioPlayerState.PLAYING); 82 | _positionController.add(new Duration(milliseconds: call.arguments)); 83 | break; 84 | case "audio.onStart": 85 | _state = AudioPlayerState.PLAYING; 86 | _playerStateController.add(AudioPlayerState.PLAYING); 87 | _duration = new Duration(milliseconds: call.arguments); 88 | break; 89 | case "audio.onPause": 90 | _state = AudioPlayerState.PAUSED; 91 | _playerStateController.add(AudioPlayerState.PAUSED); 92 | break; 93 | case "audio.onStop": 94 | _state = AudioPlayerState.STOPPED; 95 | _playerStateController.add(AudioPlayerState.STOPPED); 96 | break; 97 | case "audio.onComplete": 98 | _state = AudioPlayerState.COMPLETED; 99 | _playerStateController.add(AudioPlayerState.COMPLETED); 100 | break; 101 | case "audio.onError": 102 | // If there's an error, we assume the player has stopped. 103 | _state = AudioPlayerState.STOPPED; 104 | _playerStateController.addError(call.arguments); 105 | // to the client since each platform creates different error string 106 | // formats so we can't expect client to parse these. 107 | break; 108 | default: 109 | throw new ArgumentError('Unknown method ${call.method} '); 110 | } 111 | } 112 | } -------------------------------------------------------------------------------- /lib/helpers/flutter_toast.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | 3 | import 'package:flutter/services.dart'; 4 | 5 | class FlutterToast { 6 | static const MethodChannel _channel = const MethodChannel('flutter_toast'); 7 | 8 | static Future get platformVersion async { 9 | final String version = await _channel.invokeMethod('getPlatformVersion'); 10 | return version; 11 | } 12 | 13 | static Future showToast(String msg) async { 14 | Map args = {}; 15 | args.putIfAbsent("msg", () => msg); 16 | await _channel.invokeMethod('showToast', args); 17 | return null; 18 | } 19 | } -------------------------------------------------------------------------------- /lib/main.dart: -------------------------------------------------------------------------------- 1 | import 'dart:ui' as ui; 2 | import 'dart:async'; 3 | import 'package:flutter/material.dart'; 4 | import 'package:flutter/services.dart'; 5 | import './flutterApp.dart'; 6 | 7 | void main() => runApp(MyApp()); 8 | 9 | class MyApp extends StatelessWidget { 10 | // This widget is the root of your application. 11 | @override 12 | Widget build(BuildContext context) { 13 | return MaterialApp( 14 | themeMode: ThemeMode.dark, 15 | title: 'Flutter Demo', 16 | theme: ThemeData( 17 | primarySwatch: Colors.blue, 18 | ), 19 | home: AnnotatedRegion( 20 | value: SystemUiOverlayStyle.dark, 21 | child: FlutterApp(), 22 | ), 23 | ); 24 | } 25 | } 26 | 27 | class MyHomePage extends StatelessWidget { 28 | Widget build(BuildContext context) { 29 | Image image = new Image.network( 30 | 'https://timgsa.baidu.com/timg?image&quality=80&size=b10000_10000&sec=1564812422&di=a113f4b98d25442643ad9236f01ecbf5&src=http://hbimg.b0.upaiyun.com/0338cbe93580d5e6b0e89f25531541d455f66fda4a6a5-eVWQaf_fw658'); 31 | Completer completer = new Completer(); 32 | image.image.resolve(new ImageConfiguration()).addListener( 33 | ImageStreamListener( 34 | (ImageInfo info, bool _) => completer.complete(info.image))); 35 | return new Scaffold( 36 | appBar: new AppBar( 37 | title: new Text("Image Dimensions Example"), 38 | ), 39 | body: new ListView( 40 | children: [ 41 | new FutureBuilder( 42 | future: completer.future, 43 | builder: (BuildContext context, AsyncSnapshot snapshot) { 44 | if (snapshot.hasData) { 45 | return new Text( 46 | '${snapshot.data.width}x${snapshot.data.height}', 47 | style: Theme.of(context).textTheme.body2, 48 | ); 49 | } else { 50 | return new Text('Loading...'); 51 | } 52 | }, 53 | ), 54 | image, 55 | ], 56 | ), 57 | ); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /lib/routers/Animationted.dart: -------------------------------------------------------------------------------- 1 | import 'package:flare_flutter/provider/asset_flare.dart'; 2 | import 'package:flutter/material.dart'; 3 | import "package:flare_flutter/flare_actor.dart"; 4 | import "package:flare_flutter/flare_cache_builder.dart"; 5 | import 'package:flutter/services.dart'; 6 | 7 | class Animationted extends StatefulWidget { 8 | @override 9 | _AnimationtedState createState() => _AnimationtedState(); 10 | } 11 | 12 | class _AnimationtedState extends State { 13 | String _animationName = "idle"; 14 | final asset = AssetFlare(bundle: rootBundle, name: "assets/Filip.flr"); 15 | @override 16 | Widget build(BuildContext context) { 17 | return Scaffold( 18 | appBar: AppBar( 19 | title: Text('动画'), 20 | ), 21 | body: FlareCacheBuilder( 22 | [asset], 23 | builder: (BuildContext context, bool isWarm) { 24 | return !isWarm 25 | ? Container(child: Text("NO")) 26 | : FlareActor( 27 | "assets/Filip.flr", 28 | alignment: Alignment.center, 29 | fit: BoxFit.cover, 30 | animation: _animationName, 31 | ); 32 | }, 33 | ), 34 | ); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /lib/routers/AppLifecycleListen.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | class AppLifecycleListen extends StatefulWidget { 4 | @override 5 | _AppLifecycleListenState createState() => _AppLifecycleListenState(); 6 | } 7 | 8 | class _AppLifecycleListenState extends State 9 | with WidgetsBindingObserver { 10 | List _stateList = []; 11 | @override 12 | void initState() { 13 | super.initState(); 14 | WidgetsBinding.instance.addObserver(this); 15 | } 16 | 17 | @override 18 | void dispose() { 19 | WidgetsBinding.instance.removeObserver(this); 20 | super.dispose(); 21 | } 22 | 23 | @override 24 | void didChangeAppLifecycleState(AppLifecycleState state) { 25 | setState(() { 26 | _stateList.add('$state'); 27 | }); 28 | } 29 | 30 | Widget get _widget { 31 | if (_stateList.isEmpty) { 32 | return Center( 33 | child: Text( 34 | '将App切换到后台再返回App', 35 | style: Theme.of(context).textTheme.headline5, 36 | ), 37 | ); 38 | } 39 | return ListView( 40 | children: _stateList 41 | .map((String value) => ListTile( 42 | title: Text(value, style: TextStyle(fontSize: 18.0)), 43 | )) 44 | .toList(), 45 | ); 46 | } 47 | 48 | @override 49 | Widget build(BuildContext context) { 50 | return Scaffold( 51 | appBar: AppBar( 52 | centerTitle: true, 53 | title: Text('App状态监听'), 54 | ), 55 | body: _widget, 56 | ); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /lib/routers/AudioApp.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:audioplayers/audioplayers.dart'; 3 | 4 | enum Status { 5 | playing, 6 | end, 7 | loading, 8 | pause, 9 | } 10 | 11 | class AudioApp extends StatefulWidget { 12 | const AudioApp(); 13 | @override 14 | _AudioAppState createState() => _AudioAppState(); 15 | } 16 | 17 | class _AudioAppState extends State { 18 | AudioPlayer audioPlayer = AudioPlayer(); 19 | int _current = 0; 20 | Status _status = Status.pause; 21 | 22 | final List> _audioList = [ 23 | {'title': '父母心学', 'value': 'http://mp3.9ku.com/m4a/637791.m4a'}, 24 | { 25 | 'title': '郭德纲、于谦相声', 26 | 'value': 'http://mp3.9ku.com/m4a/473290.m4a', 27 | }, 28 | { 29 | 'title': '糗事播报', 30 | 'value': 'http://mp3.9ku.com/hot/2004/07-13/12971.mp3', 31 | }, 32 | ]; 33 | 34 | @override 35 | void initState() { 36 | super.initState(); 37 | play(); 38 | audioPlayer.setNotification( 39 | albumTitle: '《父母心学》公开课-高考的真相', 40 | artist: '蜜糖男孩', 41 | imageUrl: 42 | 'https://qpic.y.qq.com/music_cover/X52mdv6vsP6HbocN3ajjkQIoUEP69XSwf7Faedy1QPqpnl0qmG9t1A/300?n=1', 43 | duration: Duration(microseconds: 5304)); 44 | audioPlayer.onPlayerStateChanged.listen((AudioPlayerState s) { 45 | print('Current player state: $s'); 46 | // setState(() => playerState = s); 47 | }); 48 | } 49 | 50 | @override 51 | void dispose() { 52 | super.dispose(); 53 | audioPlayer.dispose(); 54 | } 55 | 56 | play() async { 57 | int result = await audioPlayer.play( 58 | 'https://video-cdn.naoxuejia.com/2b9dc617-f9ef-47a4-978d-440af0ed8db3.audio.m3u8?pm3u8/1143200&e=1576221632&token=6HXdYoPQFVMGnhmW45qWU3OvndEZz0h5aJF_y1qy:4irLs6Y0l5C-cQ0NtG--hHz-C_8='); 59 | if (result == 1) { 60 | print('播放成功'); 61 | setState(() { 62 | _status = Status.playing; 63 | }); 64 | // success 65 | } 66 | } 67 | 68 | void _togglePlay() async { 69 | if (_status == Status.pause) { 70 | int result = await audioPlayer.resume(); 71 | if (result == 1) { 72 | setState(() { 73 | _status = Status.playing; 74 | }); 75 | } 76 | return; 77 | } 78 | if (_status == Status.playing) { 79 | int result = await audioPlayer.pause(); 80 | if (result == 1) { 81 | setState(() { 82 | _status = Status.pause; 83 | }); 84 | } 85 | return; 86 | } 87 | } 88 | 89 | @override 90 | Widget build(BuildContext context) { 91 | return Scaffold( 92 | appBar: AppBar( 93 | title: Text( 94 | '${_audioList[_current]['title']}', 95 | ), 96 | ), 97 | body: Column( 98 | children: [ 99 | Container( 100 | width: double.infinity, 101 | height: 200, 102 | child: Column( 103 | children: [ 104 | SizedBox( 105 | height: 100.0, 106 | child: Align( 107 | child: Text( 108 | '正在播放:${_audioList[_current]['title']}', 109 | textAlign: TextAlign.center, 110 | style: TextStyle( 111 | fontSize: 16.0, 112 | fontWeight: FontWeight.w600, 113 | ), 114 | ), 115 | ), 116 | ), 117 | Row( 118 | mainAxisAlignment: MainAxisAlignment.spaceAround, 119 | children: [ 120 | Container( 121 | height: 40.0, 122 | color: Color(0xffededed), 123 | child: FlatButton( 124 | onPressed: () { 125 | audioPlayer.setNotification( 126 | albumTitle: 'TEST《父母心学》公开课-高考的真相', 127 | artist: '蜜糖男孩', 128 | imageUrl: 129 | 'https://qpic.y.qq.com/music_cover/X52mdv6vsP6HbocN3ajjkQIoUEP69XSwf7Faedy1QPqpnl0qmG9t1A/300?n=1', 130 | duration: Duration(microseconds: 5304)); 131 | }, 132 | child: Text('上一首'), 133 | ), 134 | ), 135 | Container( 136 | height: 40.0, 137 | color: Color(0xffededed), 138 | child: FlatButton( 139 | onPressed: _togglePlay, 140 | child: Text('${_status == Status.pause ? '播放' : '暂停'}'), 141 | ), 142 | ), 143 | Container( 144 | height: 40.0, 145 | color: Color(0xffededed), 146 | child: FlatButton( 147 | onPressed: () {}, 148 | child: Text('下一首'), 149 | ), 150 | ), 151 | ], 152 | ) 153 | ], 154 | ), 155 | ), 156 | Expanded( 157 | child: ListView.builder( 158 | itemBuilder: (BuildContext context, int index) { 159 | return Container( 160 | margin: EdgeInsets.only(top: 5.0), 161 | decoration: BoxDecoration( 162 | color: Color(0xffdedede), 163 | ), 164 | child: FlatButton( 165 | onPressed: () { 166 | setState(() { 167 | _current = index; 168 | }); 169 | }, 170 | child: SizedBox( 171 | height: 60.0, 172 | child: Align( 173 | child: Text( 174 | '${_audioList[index]['title']}', 175 | style: TextStyle(fontSize: 16.0, color: Colors.black), 176 | ), 177 | ), 178 | ), 179 | ), 180 | ); 181 | }, 182 | itemCount: _audioList.length, 183 | ), 184 | ) 185 | ], 186 | ), 187 | ); 188 | } 189 | } 190 | -------------------------------------------------------------------------------- /lib/routers/CollapseNavigation.dart: -------------------------------------------------------------------------------- 1 | import 'dart:math'; 2 | 3 | import 'package:flutter/material.dart'; 4 | import 'package:flutter/services.dart'; 5 | 6 | class CollapseNavigation extends StatefulWidget { 7 | CollapseNavigation({Key key}) : super(key: key); 8 | 9 | @override 10 | _CollapseNavigationState createState() => _CollapseNavigationState(); 11 | } 12 | 13 | class _CollapseNavigationState extends State { 14 | @override 15 | Widget build(BuildContext context) { 16 | return AnnotatedRegion( 17 | value: SystemUiOverlayStyle.light, 18 | child: Scaffold( 19 | body: CustomScrollView( 20 | slivers: [ 21 | SliverAppBar( 22 | leading: IconButton( 23 | icon: Icon(Icons.arrow_back_ios, color: Colors.black87), 24 | onPressed: () => Navigator.of(context).pop(), 25 | ), 26 | elevation: 0, 27 | floating: true, 28 | snap: true, 29 | backgroundColor: Colors.white, 30 | actions: [ 31 | IconButton( 32 | icon: Icon(Icons.more_vert, color: Colors.black87), 33 | onPressed: () {}, 34 | ), 35 | ], 36 | title: Container( 37 | height: 30.0, 38 | padding: EdgeInsets.symmetric(horizontal: 15.0), 39 | decoration: BoxDecoration( 40 | color: Color(0xffededed), 41 | borderRadius: BorderRadius.circular(40.0)), 42 | child: Align( 43 | alignment: Alignment.centerLeft, 44 | child: Text( 45 | '搜索:Flutter 小组件', 46 | style: TextStyle(fontSize: 14.0, color: Colors.black38), 47 | ), 48 | ), 49 | ), 50 | ), 51 | // SliverPersistentHeader( 52 | // pinned: true, 53 | // delegate: _SliverAppBarDelegate( 54 | // minHeight: 60.0, 55 | // maxHeight: 180.0, 56 | // child: ListView( 57 | // scrollDirection: Axis.horizontal, 58 | // children: [], 59 | // ), 60 | // ), 61 | // ), 62 | SliverFixedExtentList( 63 | itemExtent: 100.0, 64 | delegate: SliverChildListDelegate( 65 | List.generate( 66 | 60, 67 | (int index) => ListTile( 68 | title: 69 | Text('Flutter ${(index + 10).toRadixString(2)}')), 70 | ).toList(), 71 | )), 72 | ], 73 | ), 74 | ), 75 | ); 76 | } 77 | } 78 | 79 | class _SliverAppBarDelegate extends SliverPersistentHeaderDelegate { 80 | _SliverAppBarDelegate({ 81 | @required this.minHeight, 82 | @required this.maxHeight, 83 | @required this.child, 84 | }); 85 | 86 | final double minHeight; 87 | final double maxHeight; 88 | final Widget child; 89 | 90 | @override 91 | double get minExtent => minHeight; 92 | 93 | @override 94 | double get maxExtent => max(maxHeight, minHeight); 95 | 96 | @override 97 | Widget build( 98 | BuildContext context, double shrinkOffset, bool overlapsContent) { 99 | return new SizedBox.expand(child: child); 100 | } 101 | 102 | @override 103 | bool shouldRebuild(_SliverAppBarDelegate oldDelegate) { 104 | return maxHeight != oldDelegate.maxHeight || 105 | minHeight != oldDelegate.minHeight || 106 | child != oldDelegate.child; 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /lib/routers/LoginVideo.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | import 'package:flutter/material.dart'; 3 | import 'package:video_player/video_player.dart'; 4 | 5 | class LoginVideo extends StatefulWidget { 6 | const LoginVideo(); 7 | @override 8 | _LoginVideoState createState() => _LoginVideoState(); 9 | } 10 | 11 | class _LoginVideoState extends State { 12 | // 声明视频控制器 13 | VideoPlayerController _controller; 14 | // 15 | final String videoUrl = 16 | "https://video.pearvideo.com/mp4/third/20190730/cont-1584187-10136163-164150-hd.mp4"; 17 | 18 | @override 19 | void initState() { 20 | super.initState(); 21 | _controller = VideoPlayerController.network(videoUrl) 22 | ..initialize().then((_) { 23 | setState(() {}); 24 | _controller.play(); 25 | _controller.setLooping(true); 26 | // _controller.setVolume(0.0); 27 | Timer.periodic(Duration(seconds: 15), (Timer time) { 28 | print(time); 29 | }); 30 | }); 31 | } 32 | 33 | @override 34 | void dispose() { 35 | super.dispose(); 36 | _controller.pause(); 37 | } 38 | 39 | @override 40 | Widget build(BuildContext context) { 41 | return Scaffold( 42 | body: Stack( 43 | fit: StackFit.expand, 44 | children: [ 45 | Transform.scale( 46 | scale: _controller.value.aspectRatio / 47 | MediaQuery.of(context).size.aspectRatio * 48 | 1.01, 49 | child: Center( 50 | child: Container( 51 | child: _controller.value.initialized 52 | ? AspectRatio( 53 | aspectRatio: _controller.value.aspectRatio, 54 | child: VideoPlayer(_controller), 55 | ) 56 | : Text("正在初始化"), 57 | ), 58 | ), 59 | ), 60 | Positioned( 61 | width: MediaQuery.of(context).size.width, 62 | bottom: 26.0, 63 | child: Column( 64 | mainAxisAlignment: MainAxisAlignment.center, 65 | children: [ 66 | RaisedButton( 67 | shape: RoundedRectangleBorder( 68 | borderRadius: BorderRadius.all(Radius.circular(50))), 69 | onPressed: () {}, 70 | child: Container( 71 | height: 44.0, 72 | width: 240.0, 73 | child: Center( 74 | child: Text( 75 | "微信登录", 76 | style: TextStyle( 77 | fontSize: 15.0, fontWeight: FontWeight.bold), 78 | ), 79 | ), 80 | ), 81 | color: Color(0xffFFDB2E), 82 | textColor: Color(0xff202326), 83 | elevation: 0.0, 84 | focusElevation: 0.0, 85 | highlightElevation: 0.0, 86 | ), 87 | SizedBox( 88 | height: 20.0, 89 | ), 90 | RaisedButton( 91 | shape: RoundedRectangleBorder( 92 | borderRadius: BorderRadius.all(Radius.circular(50))), 93 | onPressed: () {}, 94 | child: Container( 95 | height: 44.0, 96 | width: 240.0, 97 | child: Center( 98 | child: Text( 99 | "手机号登录", 100 | style: TextStyle( 101 | fontSize: 15.0, fontWeight: FontWeight.bold), 102 | ), 103 | ), 104 | ), 105 | color: Color(0xff202326), 106 | textColor: Color(0xffededed), 107 | elevation: 0.0, 108 | focusElevation: 0.0, 109 | highlightElevation: 0.0, 110 | ), 111 | SizedBox( 112 | height: 60.0, 113 | ), 114 | Text( 115 | "我已阅读并同意《服务协议》及《隐私政策》", 116 | style: TextStyle(color: Colors.white, fontSize: 13.0), 117 | ) 118 | ], 119 | ), 120 | ), 121 | Positioned( 122 | width: MediaQuery.of(context).size.width, 123 | top: 80.0, 124 | child: Column( 125 | mainAxisAlignment: MainAxisAlignment.center, 126 | children: [ 127 | Text( 128 | "登录", 129 | style: TextStyle( 130 | fontSize: 40.0, 131 | fontWeight: FontWeight.w400, 132 | color: Colors.white), 133 | ), 134 | SizedBox( 135 | height: 10.0, 136 | ), 137 | Text( 138 | "视频背景登录页面", 139 | style: TextStyle(color: Colors.white, fontSize: 15.0), 140 | ) 141 | ], 142 | ), 143 | ) 144 | ], 145 | )); 146 | } 147 | } 148 | -------------------------------------------------------------------------------- /lib/routers/PlatformChannel.dart: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | import 'dart:async'; 6 | 7 | import 'package:flutter/material.dart'; 8 | import 'package:flutter/services.dart'; 9 | 10 | class PlatformChannel extends StatefulWidget { 11 | @override 12 | _PlatformChannelState createState() => _PlatformChannelState(); 13 | } 14 | 15 | class _PlatformChannelState extends State { 16 | static const MethodChannel methodChannel = 17 | MethodChannel('samples.flutter.io/battery'); 18 | static const EventChannel eventChannel = 19 | EventChannel('samples.flutter.io/charging'); 20 | 21 | String _batteryLevel = 'Battery level: unknown.'; 22 | String _chargingStatus = 'Battery status: unknown.'; 23 | 24 | Future _getBatteryLevel() async { 25 | String batteryLevel; 26 | try { 27 | final int result = await methodChannel.invokeMethod('getBatteryLevel'); 28 | batteryLevel = 'Battery level: $result%.'; 29 | } on PlatformException { 30 | batteryLevel = 'Failed to get battery level.'; 31 | } 32 | setState(() { 33 | _batteryLevel = batteryLevel; 34 | }); 35 | } 36 | 37 | @override 38 | void initState() { 39 | super.initState(); 40 | eventChannel.receiveBroadcastStream().listen(_onEvent, onError: _onError); 41 | } 42 | 43 | void _onEvent(Object event) { 44 | setState(() { 45 | _chargingStatus = 46 | "Battery status: ${event == 'charging' ? '' : 'dis'}charging."; 47 | }); 48 | } 49 | 50 | void _onError(Object error) { 51 | setState(() { 52 | _chargingStatus = 'Battery status: unknown.'; 53 | }); 54 | } 55 | 56 | @override 57 | Widget build(BuildContext context) { 58 | return Material( 59 | child: Column( 60 | mainAxisAlignment: MainAxisAlignment.spaceEvenly, 61 | children: [ 62 | Column( 63 | mainAxisAlignment: MainAxisAlignment.center, 64 | children: [ 65 | Text(_batteryLevel, key: const Key('Battery level label')), 66 | Padding( 67 | padding: const EdgeInsets.all(16.0), 68 | child: RaisedButton( 69 | child: const Text('Refresh'), 70 | onPressed: _getBatteryLevel, 71 | ), 72 | ), 73 | ], 74 | ), 75 | Text(_chargingStatus), 76 | ], 77 | ), 78 | ); 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /lib/routers/SlideDown.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_widget/helpers/flutter_toast.dart'; 3 | 4 | class SlideDown extends StatefulWidget { 5 | const SlideDown(); 6 | @override 7 | _SlideDownState createState() => _SlideDownState(); 8 | } 9 | 10 | class _SlideDownState extends State with TickerProviderStateMixin { 11 | AnimationController _animation; 12 | final opacityTween = Tween(begin: 0.0, end: 1.0); 13 | final positionTween = Tween( 14 | begin: const Offset(0.0, -1.0), 15 | end: Offset.zero, 16 | ); 17 | bool _visible = false; 18 | 19 | CurvedAnimation _curve; 20 | @override 21 | void initState() { 22 | super.initState(); 23 | _animation = AnimationController( 24 | vsync: this, duration: const Duration(milliseconds: 300)); 25 | _curve = CurvedAnimation( 26 | parent: _animation, 27 | curve: Curves.fastOutSlowIn, 28 | reverseCurve: Curves.decelerate, 29 | ); 30 | _animation.addListener(() {}); 31 | } 32 | 33 | @override 34 | Widget build(BuildContext context) { 35 | return Scaffold( 36 | appBar: AppBar( 37 | title: IconButton( 38 | icon: Icon(Icons.adjust), 39 | onPressed: () { 40 | FlutterToast.showToast('msg'); 41 | if (_visible) { 42 | this.setState(() { 43 | _visible = false; 44 | }); 45 | _animation.reverse(); 46 | return; 47 | } 48 | this.setState(() { 49 | _visible = true; 50 | }); 51 | _animation.forward(); 52 | }, 53 | ), 54 | ), 55 | body: Stack( 56 | overflow: Overflow.clip, 57 | children: [ 58 | Align( 59 | child: RaisedButton( 60 | onPressed: () { 61 | if (_visible) { 62 | this.setState(() { 63 | _visible = false; 64 | }); 65 | _animation.reverse(); 66 | return; 67 | } 68 | this.setState(() { 69 | _visible = true; 70 | }); 71 | _animation.forward(); 72 | }, 73 | child: Text("点我"), 74 | ), 75 | ), 76 | Positioned( 77 | child: FadeTransition( 78 | opacity: opacityTween.animate(_curve), 79 | child: GestureDetector( 80 | onTap: () { 81 | _animation.reverse(); 82 | this.setState(() { 83 | _visible = false; 84 | }); 85 | }, 86 | child: Visibility( 87 | visible: _visible, 88 | child: Container( 89 | width: MediaQuery.of(context).size.width, 90 | height: MediaQuery.of(context).size.height, 91 | color: Color.fromRGBO(0, 0, 0, 0.7), 92 | ), 93 | ), 94 | ), 95 | ), 96 | ), 97 | Positioned( 98 | top: 0.0, 99 | left: 0.0, 100 | child: FadeTransition( 101 | opacity: opacityTween.animate(_curve), 102 | child: SlideTransition( 103 | position: positionTween.animate(_curve), 104 | child: Container( 105 | width: MediaQuery.of(context).size.width, 106 | height: 300.0, 107 | color: Colors.red, 108 | ), 109 | ), 110 | ), 111 | ), 112 | ], 113 | ), 114 | ); 115 | } 116 | } 117 | -------------------------------------------------------------------------------- /lib/routers/StackNavBar.dart: -------------------------------------------------------------------------------- 1 | import 'dart:math'; 2 | import 'package:flutter/material.dart'; 3 | 4 | class StackNavBar extends StatefulWidget { 5 | @override 6 | _StackStackNavBarState createState() => _StackStackNavBarState(); 7 | } 8 | 9 | class _StackStackNavBarState extends State 10 | with TickerProviderStateMixin { 11 | AnimationController _colorAnimationController; 12 | AnimationController _textAnimationController; 13 | Animation _colorTween, _iconColorTween; 14 | Animation _transTween; 15 | 16 | @override 17 | void initState() { 18 | _colorAnimationController = 19 | AnimationController(vsync: this, duration: Duration(seconds: 0)); 20 | _colorTween = ColorTween(begin: Colors.transparent, end: Color(0xFFee4c4f)) 21 | .animate(_colorAnimationController); 22 | _iconColorTween = ColorTween(begin: Colors.grey, end: Colors.white) 23 | .animate(_colorAnimationController); 24 | 25 | _textAnimationController = 26 | AnimationController(vsync: this, duration: Duration(seconds: 0)); 27 | 28 | _transTween = Tween(begin: Offset(-10, 40), end: Offset(-10, 0)) 29 | .animate(_textAnimationController); 30 | 31 | super.initState(); 32 | } 33 | 34 | bool _scrollListener(ScrollNotification scrollInfo) { 35 | if (scrollInfo.metrics.axis == Axis.vertical && 36 | scrollInfo.metrics.pixels < 600) { 37 | _colorAnimationController.animateTo(scrollInfo.metrics.pixels / 350); 38 | 39 | _textAnimationController 40 | .animateTo((scrollInfo.metrics.pixels - 350) / 50); 41 | return true; 42 | } 43 | return false; 44 | } 45 | 46 | @override 47 | Widget build(BuildContext context) { 48 | return Scaffold( 49 | backgroundColor: Color(0xFFEEEEEE), 50 | body: NotificationListener( 51 | onNotification: _scrollListener, 52 | child: Container( 53 | height: double.infinity, 54 | child: Stack( 55 | children: [ 56 | ListView.builder( 57 | itemCount: 100, 58 | padding: EdgeInsets.zero, 59 | itemBuilder: (BuildContext context, int index) => Container( 60 | height: 150, 61 | color: Color((Random().nextDouble() * 0xFFFFFF).toInt() << 0) 62 | .withOpacity(1), 63 | width: 250, 64 | ), 65 | ), 66 | Container( 67 | height: 80, 68 | child: AnimatedBuilder( 69 | animation: _colorAnimationController, 70 | builder: (context, child) => AppBar( 71 | backgroundColor: _colorTween.value, 72 | elevation: 0, 73 | titleSpacing: 0.0, 74 | title: Transform.translate( 75 | offset: _transTween.value, 76 | child: Text( 77 | "Title", 78 | style: TextStyle( 79 | color: Colors.white, 80 | fontWeight: FontWeight.bold, 81 | fontSize: 16), 82 | ), 83 | ), 84 | iconTheme: IconThemeData( 85 | color: _iconColorTween.value, 86 | ), 87 | actions: [ 88 | IconButton( 89 | icon: Icon( 90 | Icons.local_grocery_store, 91 | ), 92 | onPressed: () { 93 | // Navigator.of(context).push(TutorialOverlay()); 94 | }, 95 | ), 96 | IconButton( 97 | icon: Icon( 98 | Icons.more_vert, 99 | ), 100 | onPressed: () {}, 101 | ), 102 | ], 103 | ), 104 | ), 105 | ), 106 | ], 107 | ), 108 | ), 109 | ), 110 | ); 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /lib/routers/StickTab.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | class StickTab extends StatefulWidget { 4 | @override 5 | _StickTabState createState() => _StickTabState(); 6 | } 7 | 8 | class _StickTabState extends State { 9 | final List _allPages = [ 10 | '语文', 11 | '英语', 12 | ]; 13 | 14 | @override 15 | void initState() { 16 | super.initState(); 17 | } 18 | 19 | @override 20 | Widget build(BuildContext context) { 21 | return DefaultTabController( 22 | length: _allPages.length, 23 | child: Scaffold( 24 | body: NestedScrollView( 25 | physics: BouncingScrollPhysics(), 26 | headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) { 27 | return [ 28 | SliverOverlapAbsorber( 29 | handle: 30 | NestedScrollView.sliverOverlapAbsorberHandleFor(context), 31 | sliver: SliverAppBar( 32 | title: const Text('Tabs and scrolling'), 33 | actions: [], 34 | pinned: true, 35 | expandedHeight: 400.0, 36 | forceElevated: innerBoxIsScrolled, 37 | bottom: TabBar( 38 | tabs: _allPages 39 | .map((String value) => Tab(text: value)) 40 | .toList(), 41 | ), 42 | ), 43 | ), 44 | ]; 45 | }, 46 | body: TabBarView( 47 | children: _allPages.map((String value) { 48 | return SafeArea( 49 | top: false, 50 | bottom: false, 51 | child: Builder( 52 | builder: (BuildContext context) { 53 | return CustomScrollView( 54 | physics: ClampingScrollPhysics(), 55 | key: PageStorageKey(value), 56 | slivers: [ 57 | SliverOverlapInjector( 58 | handle: 59 | NestedScrollView.sliverOverlapAbsorberHandleFor( 60 | context), 61 | ), 62 | SliverPadding( 63 | padding: const EdgeInsets.symmetric( 64 | vertical: 8.0, 65 | horizontal: 16.0, 66 | ), 67 | sliver: SliverFixedExtentList( 68 | itemExtent: 40.0, 69 | delegate: SliverChildBuilderDelegate( 70 | (BuildContext context, int index) { 71 | return Padding( 72 | key: ValueKey('1'), 73 | padding: const EdgeInsets.symmetric( 74 | vertical: 8.0, 75 | ), 76 | child: Text('data $index'), 77 | ); 78 | }, 79 | childCount: 350, 80 | ), 81 | ), 82 | ), 83 | ], 84 | ); 85 | }, 86 | ), 87 | ); 88 | }).toList(), 89 | ), 90 | ), 91 | ), 92 | ); 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /lib/routers/Swiper.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | class Swipe extends StatefulWidget { 4 | @override 5 | _SwipeState createState() => _SwipeState(); 6 | } 7 | 8 | class _SwipeState extends State { 9 | final List colorList = [ 10 | Colors.deepOrange, 11 | Colors.blue, 12 | Colors.amber, 13 | Colors.red, 14 | ]; 15 | @override 16 | Widget build(BuildContext context) { 17 | return Material( 18 | child: ConstrainedBox( 19 | constraints: BoxConstraints(maxHeight: 400.0), 20 | child: ListView.builder( 21 | shrinkWrap: true, 22 | padding: 23 | EdgeInsets.only(right: MediaQuery.of(context).size.width - 300.0), 24 | scrollDirection: Axis.horizontal, 25 | itemCount: colorList.length, 26 | physics: CustomScrollPhysics(itemDimension: 300.0), 27 | itemBuilder: (BuildContext context, int index) => Container( 28 | color: colorList[index], 29 | width: 300.0, 30 | height: 200.0, 31 | ), 32 | ), 33 | ), 34 | ); 35 | } 36 | } 37 | 38 | class CustomScrollPhysics extends ScrollPhysics { 39 | final double itemDimension; 40 | 41 | CustomScrollPhysics({ 42 | this.itemDimension, 43 | ScrollPhysics parent, 44 | }) : super(parent: parent); 45 | 46 | @override 47 | CustomScrollPhysics applyTo(ScrollPhysics ancestor) { 48 | return CustomScrollPhysics( 49 | itemDimension: itemDimension, 50 | parent: buildParent(ancestor), 51 | ); 52 | } 53 | 54 | double _getPage(ScrollPosition position, double portion) { 55 | return (position.pixels + portion) / itemDimension; 56 | } 57 | 58 | double _getPixels(double page, double portion) { 59 | return (page * itemDimension) - portion; 60 | } 61 | 62 | double _getTargetPixels( 63 | ScrollPosition position, 64 | Tolerance tolerance, 65 | double velocity, 66 | double portion, 67 | ) { 68 | double page = _getPage(position, portion); 69 | if (velocity < -tolerance.velocity) { 70 | page -= 0.5; 71 | } else if (velocity > tolerance.velocity) { 72 | page += 0.5; 73 | } 74 | return _getPixels(page.roundToDouble(), portion); 75 | } 76 | 77 | @override 78 | Simulation createBallisticSimulation( 79 | ScrollMetrics position, double velocity) { 80 | // If we're out of range and not headed back in range, defer to the parent 81 | // ballistics, which should put us back in range at a page boundary. 82 | if ((velocity <= 0.0 && position.pixels <= position.minScrollExtent) || 83 | (velocity >= 0.0 && position.pixels >= position.maxScrollExtent)) 84 | return super.createBallisticSimulation(position, velocity); 85 | 86 | final Tolerance tolerance = this.tolerance; 87 | // final portion = (position.extentInside - itemDimension) / 2; 88 | final portion = 0.0; 89 | final double target = 90 | _getTargetPixels(position, tolerance, velocity, portion); 91 | if (target != position.pixels) 92 | return ScrollSpringSimulation( 93 | spring, 94 | position.pixels, 95 | target, 96 | velocity, 97 | tolerance: tolerance, 98 | ); 99 | return null; 100 | } 101 | 102 | @override 103 | bool get allowImplicitScrolling => false; 104 | } 105 | -------------------------------------------------------------------------------- /lib/routers/TabBarFixed.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter/rendering.dart'; 3 | import 'package:flutter/widgets.dart'; 4 | import 'package:flutter_sticky_header/flutter_sticky_header.dart'; 5 | 6 | class _Page { 7 | const _Page( 8 | this.id, 9 | this.title, 10 | this.color, 11 | ) : assert(id != null), 12 | assert(title != null), 13 | assert(color != null); 14 | 15 | final int id; 16 | final String title; 17 | final Color color; 18 | } 19 | 20 | final List<_Page> _allPages = <_Page>[ 21 | _Page(1, 'Item 1', Colors.orange), 22 | _Page(2, 'Item 2', Colors.red), 23 | _Page(3, 'Item 3', Colors.blue), 24 | _Page(4, 'Item 4', Colors.green), 25 | ]; 26 | 27 | class TabBarFixed extends StatelessWidget { 28 | @override 29 | Widget build(BuildContext context) { 30 | return DefaultTabController( 31 | length: _allPages.length, 32 | child: Scaffold( 33 | body: NestedScrollView( 34 | headerSliverBuilder: (context, innerBoxIsScrolled) { 35 | return [ 36 | new SliverOverlapAbsorber( 37 | handle: NestedScrollView.sliverOverlapAbsorberHandleFor(context), 38 | sliver: _buildSliverAppBar(context), 39 | ), 40 | ]; 41 | }, 42 | body: new TabBarView( 43 | children: _allPages 44 | .map( 45 | (page) => SafeArea( 46 | top: false, 47 | bottom: false, 48 | child: new Builder( 49 | builder: (context) { 50 | return _buildTabBarView(context, page); 51 | }, 52 | ), 53 | ), 54 | ) 55 | .toList(), 56 | ), 57 | ), 58 | ), 59 | ); 60 | } 61 | 62 | Widget _buildTabBarView(BuildContext context, _Page page) { 63 | List slivers = new List(); 64 | 65 | slivers.add(new SliverObstructionInjector(handle: NestedScrollView.sliverOverlapAbsorberHandleFor(context))); 66 | slivers.addAll(_buildSideHeaderGrids(0, 5, page.color)); 67 | 68 | return CustomScrollView( 69 | key: PageStorageKey<_Page>(page), 70 | slivers: slivers, 71 | ); 72 | } 73 | 74 | Widget _buildSliverAppBar(BuildContext context) { 75 | return SliverAppBar( 76 | pinned: true, 77 | expandedHeight: 300.0, 78 | title: Text('Main AppBar'), 79 | bottom: TabBar( 80 | tabs: _allPages 81 | .map( 82 | (p) => new Tab( 83 | child: Text(p.title), 84 | ), 85 | ) 86 | .toList(), 87 | ), 88 | ); 89 | } 90 | 91 | List _buildSideHeaderGrids(int firstIndex, int count, Color color) { 92 | return List.generate(count, (sliverIndex) { 93 | sliverIndex += firstIndex; 94 | return new SliverStickyHeader( 95 | overlapsContent: true, 96 | header: _buildSideHeader(sliverIndex, color), 97 | sliver: new SliverPadding( 98 | padding: new EdgeInsets.only(left: 60.0), 99 | sliver: new SliverGrid( 100 | gridDelegate: new SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 3, crossAxisSpacing: 4.0, mainAxisSpacing: 4.0, childAspectRatio: 1.0), 101 | delegate: new SliverChildBuilderDelegate( 102 | (context, i) => new GridTile( 103 | child: Card( 104 | child: new Container( 105 | color: color, 106 | ), 107 | ), 108 | footer: new Container( 109 | color: Colors.white.withOpacity(0.5), 110 | child: Padding( 111 | padding: const EdgeInsets.all(8.0), 112 | child: new Text( 113 | 'Grid tile #$i', 114 | style: const TextStyle(color: Colors.black), 115 | ), 116 | ), 117 | ), 118 | ), 119 | childCount: 12, 120 | ), 121 | ), 122 | ), 123 | ); 124 | }); 125 | } 126 | 127 | Widget _buildSideHeader(int index, Color color) { 128 | return new Container( 129 | height: 60.0, 130 | color: Colors.transparent, 131 | padding: EdgeInsets.symmetric(horizontal: 16.0), 132 | alignment: Alignment.centerLeft, 133 | child: new CircleAvatar( 134 | backgroundColor: color, 135 | foregroundColor: Colors.white, 136 | child: new Text('$index'), 137 | ), 138 | ); 139 | } 140 | } 141 | 142 | class SliverObstructionInjector extends SliverOverlapInjector { 143 | /// Creates a sliver that is as tall as the value of the given [handle]'s 144 | /// layout extent. 145 | /// 146 | /// The [handle] must not be null. 147 | const SliverObstructionInjector({ 148 | Key key, 149 | @required SliverOverlapAbsorberHandle handle, 150 | Widget child, 151 | }) : assert(handle != null), 152 | super(key: key, handle: handle, sliver: child); 153 | 154 | @override 155 | RenderSliverObstructionInjector createRenderObject(BuildContext context) { 156 | return new RenderSliverObstructionInjector( 157 | handle: handle, 158 | ); 159 | } 160 | } 161 | 162 | /// A sliver that has a sliver geometry based on the values stored in a 163 | /// [SliverOverlapAbsorberHandle]. 164 | /// 165 | /// The [RenderSliverOverlapAbsorber] must be an earlier descendant of a common 166 | /// ancestor [RenderViewport] (probably a [RenderNestedScrollViewViewport]), so 167 | /// that it will always be laid out before the [RenderSliverObstructionInjector] 168 | /// during a particular frame. 169 | class RenderSliverObstructionInjector extends RenderSliverOverlapInjector { 170 | /// Creates a sliver that is as tall as the value of the given [handle]'s extent. 171 | /// 172 | /// The [handle] must not be null. 173 | RenderSliverObstructionInjector({ 174 | @required SliverOverlapAbsorberHandle handle, 175 | RenderSliver child, 176 | }) : assert(handle != null), 177 | _handle = handle, 178 | super(handle: handle); 179 | 180 | double _currentLayoutExtent; 181 | double _currentMaxExtent; 182 | 183 | /// The object that specifies how wide to make the gap injected by this render 184 | /// object. 185 | /// 186 | /// This should be a handle owned by a [RenderSliverOverlapAbsorber] and a 187 | /// [RenderNestedScrollViewViewport]. 188 | SliverOverlapAbsorberHandle get handle => _handle; 189 | SliverOverlapAbsorberHandle _handle; 190 | set handle(SliverOverlapAbsorberHandle value) { 191 | assert(value != null); 192 | if (handle == value) return; 193 | if (attached) { 194 | handle.removeListener(markNeedsLayout); 195 | } 196 | _handle = value; 197 | if (attached) { 198 | handle.addListener(markNeedsLayout); 199 | if (handle.layoutExtent != _currentLayoutExtent || handle.scrollExtent != _currentMaxExtent) markNeedsLayout(); 200 | } 201 | } 202 | 203 | @override 204 | void attach(PipelineOwner owner) { 205 | super.attach(owner); 206 | handle.addListener(markNeedsLayout); 207 | if (handle.layoutExtent != _currentLayoutExtent || handle.scrollExtent != _currentMaxExtent) markNeedsLayout(); 208 | } 209 | 210 | @override 211 | void performLayout() { 212 | _currentLayoutExtent = handle.layoutExtent; 213 | _currentMaxExtent = handle.layoutExtent; 214 | geometry = new SliverGeometry( 215 | scrollExtent: 0.0, 216 | paintExtent: _currentLayoutExtent, 217 | maxPaintExtent: _currentMaxExtent, 218 | ); 219 | } 220 | } -------------------------------------------------------------------------------- /lib/routers/UnlimitedHighCarousel.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | class PictrueData extends Object { 4 | final double width; 5 | final double height; 6 | final String url; 7 | 8 | PictrueData({this.width, this.height, this.url}); 9 | } 10 | 11 | class UnlimitedHighCarousel extends StatefulWidget { 12 | const UnlimitedHighCarousel(); 13 | 14 | @override 15 | _UnlimitedHighCarouselState createState() => _UnlimitedHighCarouselState(); 16 | } 17 | 18 | class _UnlimitedHighCarouselState extends State { 19 | num activeIndex = 0; 20 | PageController _controller; 21 | 22 | // 含有图片宽高的列表,最好是服务器返回图片的数据 23 | List pictrueList = [ 24 | PictrueData( 25 | width: 1920.0, 26 | height: 1152.0, 27 | url: 28 | "http://admin.soscoon.com/uploadImages/24294a8960f7cec4a5bb77276b8d1804eddc0023.jpg"), 29 | PictrueData( 30 | width: 550.0, 31 | height: 810.00, 32 | url: 33 | "http://admin.soscoon.com/uploadImages/72041ef01b9c8dd543511968d8659817c0086145.jpeg"), 34 | PictrueData( 35 | width: 1600.0, 36 | height: 900.00, 37 | url: 38 | "http://admin.soscoon.com/uploadImages/c236aa0af948e5d8812d23bd9eb1878682f247d8.jpg"), 39 | PictrueData( 40 | width: 1900.0, 41 | height: 1200.00, 42 | url: 43 | "http://admin.soscoon.com/uploadImages/41b2b4490204912f345b80be4fa88d7f5c9487a7.jpg"), 44 | PictrueData( 45 | width: 1920.0, 46 | height: 1000.00, 47 | url: 48 | "http://admin.soscoon.com/uploadImages/52a138c4dfcfbaab74daec69f128a2dd6dbf558f.jpg"), 49 | ]; 50 | @override 51 | void initState() { 52 | super.initState(); 53 | _controller = PageController(initialPage: 0); 54 | } 55 | 56 | @override 57 | void dispose() { 58 | super.dispose(); 59 | _controller.dispose(); 60 | } 61 | 62 | @override 63 | Widget build(BuildContext context) { 64 | double deviceWidth = MediaQuery.of(context).size.width; 65 | PictrueData pictrueData = pictrueList[activeIndex]; 66 | return Scaffold( 67 | body: Column( 68 | children: [ 69 | AnimatedContainer( 70 | duration: Duration(milliseconds: 300), 71 | height: pictrueData.height * deviceWidth / pictrueData.width, 72 | curve: Curves.ease, 73 | child: Stack( 74 | children: [ 75 | NotificationListener( 76 | onNotification: (ScrollNotification scrollInfo) { 77 | // print(scrollInfo.metrics.pixels); 78 | // print(scrollInfo.metrics.viewportDimension); 79 | // print(_controller.page); 80 | this.setState(() { 81 | this.activeIndex = _controller.page.round(); 82 | }); 83 | return true; 84 | }, 85 | child: PageView( 86 | controller: _controller, 87 | children: pictrueList 88 | .map((PictrueData data) => FadeInImage.assetNetwork( 89 | placeholder: "assets/loading_img.gif", 90 | image: data.url, 91 | fit: BoxFit.cover, 92 | alignment: Alignment.center, 93 | )) 94 | .toList()), 95 | ), 96 | Positioned( 97 | bottom: 10.0, 98 | right: 10.0, 99 | child: Container( 100 | padding: EdgeInsets.symmetric(horizontal: 5.0, vertical: 3.0), 101 | decoration: BoxDecoration( 102 | color: Color.fromRGBO(0, 0, 0, 0.5), 103 | borderRadius: BorderRadius.circular(20.0)), 104 | child: Text( 105 | '${activeIndex + 1}/${pictrueList.length}', 106 | style: TextStyle( 107 | color: const Color(0xffffffff), fontSize: 10.0), 108 | ), 109 | ), 110 | ) 111 | ], 112 | ), 113 | ), 114 | Text("文本内容") 115 | ], 116 | )); 117 | } 118 | } 119 | -------------------------------------------------------------------------------- /lib/routers/VideoPictureInPicture.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:video_player/video_player.dart'; 3 | 4 | class VideoPictureInPicture extends StatefulWidget { 5 | @override 6 | _VideoPictureInPictureState createState() => _VideoPictureInPictureState(); 7 | } 8 | 9 | class _VideoPictureInPictureState extends State { 10 | VideoPlayerController _controller01; 11 | PageController _pageController = PageController(initialPage: 0); 12 | final String videoUrl01 = 13 | 'https://video.pearvideo.com/mp4/third/20200515/cont-1674768-12719568-193822-hd.mp4'; 14 | bool _toggle = false; 15 | 16 | @override 17 | void initState() { 18 | super.initState(); 19 | _controller01 = VideoPlayerController.network(videoUrl01); 20 | _controller01.addListener(() { 21 | print(_controller01.value); 22 | }); 23 | // _pageController.nextPage( 24 | // duration: Duration(milliseconds: 400), 25 | // curve: Curves.easeOut, 26 | // ); 27 | } 28 | 29 | @override 30 | void dispose() { 31 | _controller01.dispose(); 32 | super.dispose(); 33 | } 34 | 35 | Widget get _widget01 { 36 | return AspectRatio( 37 | aspectRatio: 16 / 9, 38 | child: VideoPlayer(_controller01), 39 | ); 40 | } 41 | 42 | Widget get _widget02 { 43 | return Container( 44 | color: Colors.deepOrange, 45 | child: PageView.builder( 46 | controller: _pageController, 47 | physics: ClampingScrollPhysics(), 48 | itemBuilder: (BuildContext context, int index) => 49 | Image.asset('picture/ppt/幻灯片${index + 1}.png'), 50 | itemCount: 24, 51 | ), 52 | ); 53 | } 54 | 55 | @override 56 | Widget build(BuildContext context) { 57 | return Scaffold( 58 | body: FutureBuilder( 59 | future: Future.wait([_controller01.initialize()]), 60 | builder: (BuildContext context, AsyncSnapshot snapshot) { 61 | if (snapshot.hasData) { 62 | _controller01.play(); 63 | return Stack( 64 | children: [ 65 | Visibility( 66 | visible: _toggle, 67 | child: _widget01, 68 | ), 69 | Visibility( 70 | visible: _toggle, 71 | child: _widget02, 72 | ), 73 | Positioned( 74 | width: 200.0, 75 | height: 112.5, 76 | bottom: 10.0, 77 | right: 10.0, 78 | child: GestureDetector( 79 | onTap: () => setState(() { 80 | _toggle = !_toggle; 81 | }), 82 | child: _toggle ? _widget02 : _widget01, 83 | ), 84 | ), 85 | ], 86 | ); 87 | } 88 | return Center( 89 | child: Text( 90 | '视频加载中', 91 | style: Theme.of(context).textTheme.bodyText2, 92 | ), 93 | ); 94 | }, 95 | ), 96 | ); 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /lib/routers/carousel_zoom.dart: -------------------------------------------------------------------------------- 1 | import 'dart:math' as math; 2 | import 'package:flutter/material.dart'; 3 | 4 | const _horizontalPadding = 32.0; 5 | const _carouselItemMargin = 8.0; 6 | const _carouselHeightMin = 200.0 + 2 * _carouselItemMargin; 7 | 8 | class CarouselZoom extends StatefulWidget { 9 | const CarouselZoom(); 10 | @override 11 | _CarouselZoomState createState() => _CarouselZoomState(); 12 | } 13 | 14 | class _CarouselZoomState extends State 15 | with SingleTickerProviderStateMixin { 16 | AnimationController _animationController; 17 | 18 | @override 19 | void initState() { 20 | super.initState(); 21 | _animationController = AnimationController( 22 | vsync: this, 23 | duration: const Duration(milliseconds: 800), 24 | ); 25 | } 26 | 27 | @override 28 | Widget build(BuildContext context) { 29 | return Scaffold( 30 | body: _Carousel( 31 | children: [ 32 | Container( 33 | color: Colors.green, 34 | width: MediaQuery.of(context).size.width - 60, 35 | height: 160.0, 36 | ), 37 | Container( 38 | color: Colors.red, 39 | width: MediaQuery.of(context).size.width - 60, 40 | height: 160.0, 41 | ), 42 | Container( 43 | color: Colors.blue, 44 | width: MediaQuery.of(context).size.width - 60, 45 | height: 160.0, 46 | ), 47 | Container( 48 | color: Colors.blue, 49 | width: MediaQuery.of(context).size.width - 60, 50 | height: 160.0, 51 | ), 52 | Container( 53 | color: Colors.blue, 54 | width: MediaQuery.of(context).size.width - 60, 55 | height: 160.0, 56 | ), 57 | Container( 58 | color: Colors.blue, 59 | width: MediaQuery.of(context).size.width - 60, 60 | height: 160.0, 61 | ), 62 | ], 63 | animationController: _animationController, 64 | ), 65 | ); 66 | } 67 | } 68 | 69 | class _Carousel extends StatefulWidget { 70 | const _Carousel({ 71 | Key key, 72 | this.children, 73 | this.animationController, 74 | }) : super(key: key); 75 | 76 | final List children; 77 | final AnimationController animationController; 78 | 79 | @override 80 | _CarouselState createState() => _CarouselState(); 81 | } 82 | 83 | class _CarouselState extends State<_Carousel> 84 | with SingleTickerProviderStateMixin { 85 | PageController _controller; 86 | int _currentPage = 0; 87 | 88 | @override 89 | void didChangeDependencies() { 90 | super.didChangeDependencies(); 91 | if (_controller == null) { 92 | // The viewPortFraction is calculated as the width of the device minus the 93 | // padding. 94 | final width = MediaQuery.of(context).size.width; 95 | final padding = (_horizontalPadding * 2) - (_carouselItemMargin * 2); 96 | _controller = PageController( 97 | initialPage: _currentPage, 98 | viewportFraction: (width - padding) / width, 99 | ); 100 | } 101 | } 102 | 103 | @override 104 | void dispose() { 105 | _controller.dispose(); 106 | super.dispose(); 107 | } 108 | 109 | Widget builder(int index) { 110 | final carouselCard = AnimatedBuilder( 111 | animation: _controller, 112 | builder: (context, child) { 113 | double value; 114 | if (_controller.position.haveDimensions) { 115 | value = _controller.page - index; 116 | } else { 117 | // If haveDimensions is false, use _currentPage to calculate value. 118 | value = (_currentPage - index).toDouble(); 119 | } 120 | // We want the peeking cards to be 160 in height and 0.38 helps 121 | // achieve that. 122 | value = (1 - (value.abs() * .38)).clamp(0, 1).toDouble(); 123 | value = Curves.easeOut.transform(value); 124 | 125 | return Center( 126 | child: Transform( 127 | transform: Matrix4.diagonal3Values(1.0, value, 1.0), 128 | alignment: Alignment.center, 129 | child: child, 130 | ), 131 | ); 132 | }, 133 | child: widget.children[index], 134 | ); 135 | return carouselCard; 136 | } 137 | 138 | @override 139 | Widget build(BuildContext context) { 140 | return _AnimatedCarousel( 141 | child: PageView.builder( 142 | // Makes integration tests possible. 143 | key: const ValueKey('studyDemoList'), 144 | onPageChanged: (value) { 145 | setState(() { 146 | _currentPage = value; 147 | }); 148 | }, 149 | controller: _controller, 150 | itemCount: widget.children.length, 151 | itemBuilder: (context, index) => builder(index), 152 | allowImplicitScrolling: true, 153 | ), 154 | controller: widget.animationController, 155 | ); 156 | } 157 | } 158 | 159 | double _carouselHeight(double scaleFactor, BuildContext context) => math.max( 160 | _carouselHeightMin * MediaQuery.of(context).textScaleFactor * scaleFactor, 161 | _carouselHeightMin); 162 | 163 | class _AnimatedCarousel extends StatelessWidget { 164 | _AnimatedCarousel({ 165 | Key key, 166 | @required this.child, 167 | @required this.controller, 168 | }) : startPositionAnimation = Tween( 169 | begin: 1.0, 170 | end: 0.0, 171 | ).animate( 172 | CurvedAnimation( 173 | parent: controller, 174 | curve: const Interval( 175 | 0.200, 176 | 0.800, 177 | curve: Curves.ease, 178 | ), 179 | ), 180 | ), 181 | super(key: key); 182 | 183 | final Widget child; 184 | final AnimationController controller; 185 | final Animation startPositionAnimation; 186 | 187 | @override 188 | Widget build(BuildContext context) { 189 | return LayoutBuilder(builder: (context, constraints) { 190 | return AnimatedBuilder( 191 | animation: controller, 192 | builder: (context, child) { 193 | return child; 194 | }, 195 | child: Container( 196 | height: _carouselHeight(.4, context), 197 | width: constraints.maxWidth, 198 | child: child, 199 | ), 200 | ); 201 | }); 202 | } 203 | } 204 | -------------------------------------------------------------------------------- /lib/routers/fold_list.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | class FoldList extends StatefulWidget { 4 | @override 5 | _FoldListState createState() => _FoldListState(); 6 | } 7 | 8 | class _FoldListState extends State { 9 | double _height = 200; 10 | @override 11 | Widget build(BuildContext context) { 12 | return Scaffold( 13 | body: SafeArea( 14 | child: NotificationListener( 15 | onNotification: (ScrollNotification notification) { 16 | ScrollMetrics metrics = notification.metrics; 17 | return true; 18 | }, 19 | child: ListView.builder( 20 | itemCount: 15, 21 | itemBuilder: (BuildContext context, int index) { 22 | if (index == 4) { 23 | return AnimatedContainer( 24 | duration: Duration(milliseconds: 200), 25 | curve: Curves.easeInOutCirc, 26 | margin: EdgeInsets.symmetric(horizontal: 15.0).copyWith( 27 | bottom: 10.0, 28 | ), 29 | decoration: BoxDecoration(color: Colors.blueAccent), 30 | height: _height, 31 | child: IconButton( 32 | onPressed: () => this 33 | .setState(() => _height = _height == 200 ? 40 : 200), 34 | icon: Icon(_height == 200 35 | ? Icons.arrow_circle_up_outlined 36 | : Icons.arrow_circle_down_rounded), 37 | ), 38 | ); 39 | } 40 | return Container( 41 | margin: EdgeInsets.symmetric(horizontal: 15.0).copyWith( 42 | bottom: 10.0, 43 | ), 44 | decoration: BoxDecoration(color: Colors.black12), 45 | height: 40.0, 46 | ); 47 | }, 48 | ), 49 | ), 50 | ), 51 | ); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /lib/widgets/TabContainer.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter/rendering.dart'; 3 | 4 | import 'package:flutter/foundation.dart'; 5 | import 'dart:ui' as ui; 6 | 7 | ///** 8 | // * 自定义的TabBar 9 | // * 因为原生的tabbar无法改变宽高,因此无法自定义 10 | // * 这里是自定义的,实现了PreferredSizeWidget,因为在AppBar的bottom属性里,只支持PreferredSizeWidget这样的widget 11 | // * 同时是此控件还能设置padding 12 | // */ 13 | class TabContainer extends StatelessWidget implements PreferredSizeWidget { 14 | /// Creates a widget that combines common painting, positioning, and sizing widgets. 15 | /// 16 | /// The `height` and `width` values include the padding. 17 | /// 18 | /// The `color` argument is a shorthand for `decoration: new 19 | /// BoxDecoration(color: color)`, which means you cannot supply both a `color` 20 | /// and a `decoration` argument. If you want to have both a `color` and a 21 | /// `decoration`, you can pass the color as the `color` argument to the 22 | /// `BoxDecoration`. 23 | TabContainer({ 24 | Key key, 25 | this.alignment, 26 | this.padding, 27 | Color color, 28 | Decoration decoration, 29 | this.foregroundDecoration, 30 | this.width, 31 | this.height, 32 | BoxConstraints constraints, 33 | this.margin, 34 | this.transform, 35 | this.child, 36 | }) : assert(margin == null || margin.isNonNegative), 37 | assert(padding == null || padding.isNonNegative), 38 | assert(decoration == null || decoration.debugAssertIsValid()), 39 | assert(constraints == null || constraints.debugAssertIsValid()), 40 | assert( 41 | color == null || decoration == null, 42 | 'Cannot provide both a color and a decoration\n' 43 | 'The color argument is just a shorthand for "decoration: new BoxDecoration(color: color)".'), 44 | decoration = 45 | decoration ?? (color != null ? BoxDecoration(color: color) : null), 46 | constraints = (width != null || height != null) 47 | ? constraints?.tighten(width: width, height: height) ?? 48 | BoxConstraints.tightFor(width: width, height: height) 49 | : constraints, 50 | super(key: key); 51 | 52 | /// If non-null, requires the child to have exactly this width. 53 | double width; 54 | 55 | /// If non-null, requires the child to have exactly this height. 56 | final double height; 57 | 58 | /// The [child] contained by the container. 59 | /// 60 | /// If null, and if the [constraints] are unbounded or also null, the 61 | /// container will expand to fill all available space in its parent, unless 62 | /// the parent provides unbounded constraints, in which case the container 63 | /// will attempt to be as small as possible. 64 | /// 65 | /// {@macro flutter.widgets.child} 66 | final Widget child; 67 | 68 | /// Align the [child] within the container. 69 | /// 70 | /// If non-null, the container will expand to fill its parent and position its 71 | /// child within itself according to the given value. If the incoming 72 | /// constraints are unbounded, then the child will be shrink-wrapped instead. 73 | /// 74 | /// Ignored if [child] is null. 75 | /// 76 | /// See also: 77 | /// 78 | /// * [Alignment], a class with convenient constants typically used to 79 | /// specify an [AlignmentGeometry]. 80 | /// * [AlignmentDirectional], like [Alignment] for specifying alignments 81 | /// relative to text direction. 82 | final AlignmentGeometry alignment; 83 | 84 | /// Empty space to inscribe inside the [decoration]. The [child], if any, is 85 | /// placed inside this padding. 86 | /// 87 | /// This padding is in addition to any padding inherent in the [decoration]; 88 | /// see [Decoration.padding]. 89 | final EdgeInsetsGeometry padding; 90 | 91 | /// The decoration to paint behind the [child]. 92 | /// 93 | /// A shorthand for specifying just a solid color is available in the 94 | /// constructor: set the `color` argument instead of the `decoration` 95 | /// argument. 96 | final Decoration decoration; 97 | 98 | /// The decoration to paint in front of the [child]. 99 | final Decoration foregroundDecoration; 100 | 101 | /// Additional constraints to apply to the child. 102 | /// 103 | /// The constructor `width` and `height` arguments are combined with the 104 | /// `constraints` argument to set this property. 105 | /// 106 | /// The [padding] goes inside the constraints. 107 | final BoxConstraints constraints; 108 | 109 | /// Empty space to surround the [decoration] and [child]. 110 | final EdgeInsetsGeometry margin; 111 | 112 | /// The transformation matrix to apply before painting the container. 113 | final Matrix4 transform; 114 | 115 | EdgeInsetsGeometry get _paddingIncludingDecoration { 116 | if (decoration == null || decoration.padding == null) return padding; 117 | final EdgeInsetsGeometry decorationPadding = decoration.padding; 118 | if (padding == null) return decorationPadding; 119 | return padding.add(decorationPadding); 120 | } 121 | 122 | @override 123 | Widget build(BuildContext context) { 124 | Widget current = child; 125 | 126 | if (child == null && (constraints == null || !constraints.isTight)) { 127 | current = LimitedBox( 128 | maxWidth: 0.0, 129 | maxHeight: 0.0, 130 | child: ConstrainedBox(constraints: const BoxConstraints.expand())); 131 | } 132 | 133 | if (alignment != null) 134 | current = Align(alignment: alignment, child: current); 135 | 136 | final EdgeInsetsGeometry effectivePadding = _paddingIncludingDecoration; 137 | if (effectivePadding != null) 138 | current = Padding(padding: effectivePadding, child: current); 139 | 140 | if (decoration != null) 141 | current = DecoratedBox(decoration: decoration, child: current); 142 | 143 | if (foregroundDecoration != null) { 144 | current = DecoratedBox( 145 | decoration: foregroundDecoration, 146 | position: DecorationPosition.foreground, 147 | child: current); 148 | } 149 | 150 | if (constraints != null) 151 | current = ConstrainedBox(constraints: constraints, child: current); 152 | 153 | if (margin != null) current = Padding(padding: margin, child: current); 154 | 155 | if (transform != null) 156 | current = Transform(transform: transform, child: current); 157 | 158 | return current; 159 | } 160 | 161 | @override 162 | void debugFillProperties(DiagnosticPropertiesBuilder properties) { 163 | super.debugFillProperties(properties); 164 | properties.add(DiagnosticsProperty( 165 | 'alignment', alignment, 166 | showName: false, defaultValue: null)); 167 | properties.add(DiagnosticsProperty('padding', padding, 168 | defaultValue: null)); 169 | properties.add( 170 | DiagnosticsProperty('bg', decoration, defaultValue: null)); 171 | properties.add(DiagnosticsProperty('fg', foregroundDecoration, 172 | defaultValue: null)); 173 | properties.add(DiagnosticsProperty( 174 | 'constraints', constraints, 175 | defaultValue: null)); 176 | properties.add(DiagnosticsProperty('margin', margin, 177 | defaultValue: null)); 178 | properties.add(ObjectFlagProperty.has('transform', transform)); 179 | } 180 | 181 | @override 182 | Size get preferredSize => Size( 183 | width = width ?? MediaQueryData.fromWindow(ui.window).size.width, 184 | height ?? 60); 185 | } 186 | -------------------------------------------------------------------------------- /lib/widgets/stick_render.dart: -------------------------------------------------------------------------------- 1 | import 'dart:math' as math; 2 | 3 | import 'package:flutter/material.dart'; 4 | import 'package:flutter/rendering.dart'; 5 | 6 | class StickRender extends RenderBox 7 | with 8 | ContainerRenderObjectMixin, 9 | RenderBoxContainerDefaultsMixin { 10 | StickRender({@required ScrollableState scrollable}) { 11 | this._scrollable = scrollable; 12 | } 13 | 14 | ScrollableState _scrollable; 15 | 16 | set scrollable(ScrollableState scrollableState) { 17 | if (_scrollable == scrollableState) { 18 | return; 19 | } 20 | final ScrollableState preScroll = _scrollable; 21 | _scrollable = scrollableState; 22 | if (attached) { 23 | ///这里触发更新 24 | preScroll.position?.removeListener(markNeedsLayout); 25 | scrollableState.position?.addListener(markNeedsLayout); 26 | } 27 | markNeedsLayout(); 28 | } 29 | 30 | double getScrollAbleDy() { 31 | RenderObject renderObject = _scrollable.context.findRenderObject(); 32 | if (!renderObject.attached) { 33 | return 0; 34 | } 35 | try { 36 | return localToGlobal(Offset.zero, ancestor: renderObject).dy; 37 | } catch (e) { 38 | print(e); 39 | } 40 | return 0; 41 | } 42 | 43 | @override 44 | void attach(_) { 45 | ///设置监听 46 | _scrollable.position?.addListener(markNeedsLayout); 47 | super.attach(_); 48 | } 49 | 50 | @override 51 | void detach() { 52 | _scrollable.position?.removeListener(markNeedsLayout); 53 | super.detach(); 54 | } 55 | 56 | ///设置为 isRepaintBoundary 或者性能会好一些。 57 | ///@override 58 | ///bool get isRepaintBoundary => true; 59 | 60 | @override 61 | double computeMinIntrinsicHeight(double width) { 62 | return (lastChild.getMinIntrinsicHeight(width) + 63 | firstChild.getMinIntrinsicHeight(width)); 64 | } 65 | 66 | @override 67 | double computeMaxIntrinsicHeight(double width) { 68 | return (lastChild.getMaxIntrinsicHeight(width) + 69 | firstChild.getMaxIntrinsicHeight(width)); 70 | } 71 | 72 | @override 73 | double computeDistanceToActualBaseline(TextBaseline baseline) { 74 | return defaultComputeDistanceToHighestActualBaseline(baseline); 75 | } 76 | 77 | ///设置绘制默认 78 | @override 79 | void paint(PaintingContext context, Offset offset) { 80 | defaultPaint(context, offset); 81 | } 82 | 83 | ///设置我们的 StickParentData 84 | @override 85 | void setupParentData(RenderObject child) { 86 | super.setupParentData(child); 87 | if (child.parentData is! StickParentData) { 88 | child.parentData = new StickParentData(); 89 | } 90 | } 91 | 92 | @override 93 | void performLayout() { 94 | var header = lastChild; 95 | var content = firstChild; 96 | 97 | ///取消最小宽高 98 | var loosenConstraints = constraints.loosen(); 99 | content.layout(loosenConstraints, parentUsesSize: true); 100 | header.layout(loosenConstraints, parentUsesSize: true); 101 | 102 | ///获取各自的高度用户计算 103 | var contentHeight = content.size.height; 104 | var headerHeight = header.size.height; 105 | 106 | ///对于当前布局,用内容作为宽高 107 | var width = content.size.width; 108 | var height = headerHeight + contentHeight; 109 | size = new Size(width, height); 110 | 111 | ///内容的初始化位置 112 | (content.parentData as StickParentData).offset = 113 | new Offset(0, headerHeight); 114 | 115 | /// 计算出 header 需要的整体偏移量,用于反方向 116 | var headerOffset = height - headerHeight; 117 | 118 | ///判断当前 item 在 ScrollAble 里的偏移 119 | var scrollAbleDy = getScrollAbleDy(); 120 | 121 | ///是滑动的多还是偏移量 122 | var realHeaderOffset = math.min(-scrollAbleDy, headerOffset); 123 | (header.parentData as StickParentData).offset = 124 | new Offset(0, math.max(0, realHeaderOffset)); 125 | } 126 | 127 | @override 128 | bool hitTestChildren(HitTestResult result, {Offset position}) { 129 | return defaultHitTestChildren(result, position: position); 130 | } 131 | } 132 | 133 | class StickParentData extends ContainerBoxParentData {} 134 | -------------------------------------------------------------------------------- /lib/widgets/stick_widget.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import './stick_render.dart'; 3 | 4 | class StickWidget extends MultiChildRenderObjectWidget { 5 | ///顺序添加 stickHeader 和 stickContent 6 | StickWidget({ 7 | @required stickHeader, 8 | @required stickContent, 9 | }) : super( 10 | ///如果反过来,会有意想不到的效果哦 11 | children: [stickContent, stickHeader], 12 | ); 13 | 14 | @override 15 | StickRender createRenderObject(BuildContext context) { 16 | ///传入 ScrollableState 17 | return new StickRender(scrollable: Scrollable.of(context)); 18 | } 19 | 20 | @override 21 | void updateRenderObject(BuildContext context, StickRender renderObject) { 22 | renderObject..scrollable = Scrollable.of(context); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /picture/QRCode_258.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tecode/flutter_widget/3a22898c58114bd942162ca1fc7bbdcef9396430/picture/QRCode_258.png -------------------------------------------------------------------------------- /picture/Screenrecorder-2020-02-24-14-30-23-661.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tecode/flutter_widget/3a22898c58114bd942162ca1fc7bbdcef9396430/picture/Screenrecorder-2020-02-24-14-30-23-661.gif -------------------------------------------------------------------------------- /picture/Screenshot_2020-02-24-14-37-21-470_com.android.settings.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tecode/flutter_widget/3a22898c58114bd942162ca1fc7bbdcef9396430/picture/Screenshot_2020-02-24-14-37-21-470_com.android.settings.jpg -------------------------------------------------------------------------------- /picture/app_lifecycle_listen.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tecode/flutter_widget/3a22898c58114bd942162ca1fc7bbdcef9396430/picture/app_lifecycle_listen.gif -------------------------------------------------------------------------------- /picture/auto_height_carousel.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tecode/flutter_widget/3a22898c58114bd942162ca1fc7bbdcef9396430/picture/auto_height_carousel.gif -------------------------------------------------------------------------------- /picture/collapse_navigation.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tecode/flutter_widget/3a22898c58114bd942162ca1fc7bbdcef9396430/picture/collapse_navigation.gif -------------------------------------------------------------------------------- /picture/login_video_demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tecode/flutter_widget/3a22898c58114bd942162ca1fc7bbdcef9396430/picture/login_video_demo.gif -------------------------------------------------------------------------------- /picture/stack_navbar.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tecode/flutter_widget/3a22898c58114bd942162ca1fc7bbdcef9396430/picture/stack_navbar.gif -------------------------------------------------------------------------------- /picture/swipe.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tecode/flutter_widget/3a22898c58114bd942162ca1fc7bbdcef9396430/picture/swipe.gif -------------------------------------------------------------------------------- /picture/tapd_59861796_base64_1589612431_37.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tecode/flutter_widget/3a22898c58114bd942162ca1fc7bbdcef9396430/picture/tapd_59861796_base64_1589612431_37.png -------------------------------------------------------------------------------- /pubspec.lock: -------------------------------------------------------------------------------- 1 | # Generated by pub 2 | # See https://dart.dev/tools/pub/glossary#lockfile 3 | packages: 4 | async: 5 | dependency: transitive 6 | description: 7 | name: async 8 | url: "https://pub.flutter-io.cn" 9 | source: hosted 10 | version: "2.5.0-nullsafety.1" 11 | audioplayers: 12 | dependency: "direct dev" 13 | description: 14 | name: audioplayers 15 | url: "https://pub.flutter-io.cn" 16 | source: hosted 17 | version: "0.15.1" 18 | boolean_selector: 19 | dependency: transitive 20 | description: 21 | name: boolean_selector 22 | url: "https://pub.flutter-io.cn" 23 | source: hosted 24 | version: "2.1.0-nullsafety.1" 25 | characters: 26 | dependency: transitive 27 | description: 28 | name: characters 29 | url: "https://pub.flutter-io.cn" 30 | source: hosted 31 | version: "1.1.0-nullsafety.3" 32 | charcode: 33 | dependency: transitive 34 | description: 35 | name: charcode 36 | url: "https://pub.flutter-io.cn" 37 | source: hosted 38 | version: "1.2.0-nullsafety.1" 39 | chewie: 40 | dependency: "direct dev" 41 | description: 42 | name: chewie 43 | url: "https://pub.flutter-io.cn" 44 | source: hosted 45 | version: "0.9.10" 46 | clock: 47 | dependency: transitive 48 | description: 49 | name: clock 50 | url: "https://pub.flutter-io.cn" 51 | source: hosted 52 | version: "1.1.0-nullsafety.1" 53 | collection: 54 | dependency: transitive 55 | description: 56 | name: collection 57 | url: "https://pub.flutter-io.cn" 58 | source: hosted 59 | version: "1.15.0-nullsafety.3" 60 | convert: 61 | dependency: transitive 62 | description: 63 | name: convert 64 | url: "https://pub.flutter-io.cn" 65 | source: hosted 66 | version: "2.1.1" 67 | crypto: 68 | dependency: transitive 69 | description: 70 | name: crypto 71 | url: "https://pub.flutter-io.cn" 72 | source: hosted 73 | version: "2.1.4" 74 | cupertino_icons: 75 | dependency: "direct main" 76 | description: 77 | name: cupertino_icons 78 | url: "https://pub.flutter-io.cn" 79 | source: hosted 80 | version: "0.1.3" 81 | fake_async: 82 | dependency: transitive 83 | description: 84 | name: fake_async 85 | url: "https://pub.flutter-io.cn" 86 | source: hosted 87 | version: "1.2.0-nullsafety.1" 88 | ffi: 89 | dependency: transitive 90 | description: 91 | name: ffi 92 | url: "https://pub.flutter-io.cn" 93 | source: hosted 94 | version: "0.1.3" 95 | file: 96 | dependency: transitive 97 | description: 98 | name: file 99 | url: "https://pub.flutter-io.cn" 100 | source: hosted 101 | version: "5.2.1" 102 | flare_dart: 103 | dependency: transitive 104 | description: 105 | name: flare_dart 106 | url: "https://pub.flutter-io.cn" 107 | source: hosted 108 | version: "2.3.4" 109 | flare_flutter: 110 | dependency: "direct main" 111 | description: 112 | name: flare_flutter 113 | url: "https://pub.flutter-io.cn" 114 | source: hosted 115 | version: "2.0.3" 116 | flutter: 117 | dependency: "direct main" 118 | description: flutter 119 | source: sdk 120 | version: "0.0.0" 121 | flutter_sticky_header: 122 | dependency: "direct main" 123 | description: 124 | name: flutter_sticky_header 125 | url: "https://pub.flutter-io.cn" 126 | source: hosted 127 | version: "0.4.2" 128 | flutter_test: 129 | dependency: "direct dev" 130 | description: flutter 131 | source: sdk 132 | version: "0.0.0" 133 | flutter_web_plugins: 134 | dependency: transitive 135 | description: flutter 136 | source: sdk 137 | version: "0.0.0" 138 | http: 139 | dependency: "direct dev" 140 | description: 141 | name: http 142 | url: "https://pub.flutter-io.cn" 143 | source: hosted 144 | version: "0.12.2" 145 | http_parser: 146 | dependency: transitive 147 | description: 148 | name: http_parser 149 | url: "https://pub.flutter-io.cn" 150 | source: hosted 151 | version: "3.1.4" 152 | intl: 153 | dependency: transitive 154 | description: 155 | name: intl 156 | url: "https://pub.flutter-io.cn" 157 | source: hosted 158 | version: "0.16.1" 159 | matcher: 160 | dependency: transitive 161 | description: 162 | name: matcher 163 | url: "https://pub.flutter-io.cn" 164 | source: hosted 165 | version: "0.12.10-nullsafety.1" 166 | meta: 167 | dependency: transitive 168 | description: 169 | name: meta 170 | url: "https://pub.flutter-io.cn" 171 | source: hosted 172 | version: "1.3.0-nullsafety.3" 173 | open_iconic_flutter: 174 | dependency: transitive 175 | description: 176 | name: open_iconic_flutter 177 | url: "https://pub.flutter-io.cn" 178 | source: hosted 179 | version: "0.3.0" 180 | path: 181 | dependency: transitive 182 | description: 183 | name: path 184 | url: "https://pub.flutter-io.cn" 185 | source: hosted 186 | version: "1.8.0-nullsafety.1" 187 | path_provider: 188 | dependency: "direct dev" 189 | description: 190 | name: path_provider 191 | url: "https://pub.flutter-io.cn" 192 | source: hosted 193 | version: "1.6.16" 194 | path_provider_linux: 195 | dependency: transitive 196 | description: 197 | name: path_provider_linux 198 | url: "https://pub.flutter-io.cn" 199 | source: hosted 200 | version: "0.0.1+2" 201 | path_provider_macos: 202 | dependency: transitive 203 | description: 204 | name: path_provider_macos 205 | url: "https://pub.flutter-io.cn" 206 | source: hosted 207 | version: "0.0.4+4" 208 | path_provider_platform_interface: 209 | dependency: transitive 210 | description: 211 | name: path_provider_platform_interface 212 | url: "https://pub.flutter-io.cn" 213 | source: hosted 214 | version: "1.0.3" 215 | path_provider_windows: 216 | dependency: transitive 217 | description: 218 | name: path_provider_windows 219 | url: "https://pub.flutter-io.cn" 220 | source: hosted 221 | version: "0.0.3" 222 | pedantic: 223 | dependency: transitive 224 | description: 225 | name: pedantic 226 | url: "https://pub.flutter-io.cn" 227 | source: hosted 228 | version: "1.9.0" 229 | platform: 230 | dependency: transitive 231 | description: 232 | name: platform 233 | url: "https://pub.flutter-io.cn" 234 | source: hosted 235 | version: "2.2.1" 236 | plugin_platform_interface: 237 | dependency: transitive 238 | description: 239 | name: plugin_platform_interface 240 | url: "https://pub.flutter-io.cn" 241 | source: hosted 242 | version: "1.0.2" 243 | process: 244 | dependency: transitive 245 | description: 246 | name: process 247 | url: "https://pub.flutter-io.cn" 248 | source: hosted 249 | version: "3.0.13" 250 | sky_engine: 251 | dependency: transitive 252 | description: flutter 253 | source: sdk 254 | version: "0.0.99" 255 | source_span: 256 | dependency: transitive 257 | description: 258 | name: source_span 259 | url: "https://pub.flutter-io.cn" 260 | source: hosted 261 | version: "1.8.0-nullsafety.2" 262 | stack_trace: 263 | dependency: transitive 264 | description: 265 | name: stack_trace 266 | url: "https://pub.flutter-io.cn" 267 | source: hosted 268 | version: "1.10.0-nullsafety.1" 269 | stream_channel: 270 | dependency: transitive 271 | description: 272 | name: stream_channel 273 | url: "https://pub.flutter-io.cn" 274 | source: hosted 275 | version: "2.1.0-nullsafety.1" 276 | string_scanner: 277 | dependency: transitive 278 | description: 279 | name: string_scanner 280 | url: "https://pub.flutter-io.cn" 281 | source: hosted 282 | version: "1.1.0-nullsafety.1" 283 | term_glyph: 284 | dependency: transitive 285 | description: 286 | name: term_glyph 287 | url: "https://pub.flutter-io.cn" 288 | source: hosted 289 | version: "1.2.0-nullsafety.1" 290 | test_api: 291 | dependency: transitive 292 | description: 293 | name: test_api 294 | url: "https://pub.flutter-io.cn" 295 | source: hosted 296 | version: "0.2.19-nullsafety.2" 297 | typed_data: 298 | dependency: transitive 299 | description: 300 | name: typed_data 301 | url: "https://pub.flutter-io.cn" 302 | source: hosted 303 | version: "1.3.0-nullsafety.3" 304 | uuid: 305 | dependency: transitive 306 | description: 307 | name: uuid 308 | url: "https://pub.flutter-io.cn" 309 | source: hosted 310 | version: "2.2.2" 311 | vector_math: 312 | dependency: transitive 313 | description: 314 | name: vector_math 315 | url: "https://pub.flutter-io.cn" 316 | source: hosted 317 | version: "2.1.0-nullsafety.3" 318 | video_player: 319 | dependency: "direct dev" 320 | description: 321 | name: video_player 322 | url: "https://pub.flutter-io.cn" 323 | source: hosted 324 | version: "0.10.11+1" 325 | video_player_platform_interface: 326 | dependency: transitive 327 | description: 328 | name: video_player_platform_interface 329 | url: "https://pub.flutter-io.cn" 330 | source: hosted 331 | version: "2.1.1" 332 | video_player_web: 333 | dependency: transitive 334 | description: 335 | name: video_player_web 336 | url: "https://pub.flutter-io.cn" 337 | source: hosted 338 | version: "0.1.3+2" 339 | wakelock: 340 | dependency: transitive 341 | description: 342 | name: wakelock 343 | url: "https://pub.flutter-io.cn" 344 | source: hosted 345 | version: "0.1.4+2" 346 | win32: 347 | dependency: transitive 348 | description: 349 | name: win32 350 | url: "https://pub.flutter-io.cn" 351 | source: hosted 352 | version: "1.7.3" 353 | xdg_directories: 354 | dependency: transitive 355 | description: 356 | name: xdg_directories 357 | url: "https://pub.flutter-io.cn" 358 | source: hosted 359 | version: "0.1.0" 360 | sdks: 361 | dart: ">=2.10.0-110 <2.11.0" 362 | flutter: ">=1.12.13+hotfix.5 <2.0.0" 363 | -------------------------------------------------------------------------------- /pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: flutter_widget 2 | description: A new Flutter project. 3 | 4 | # The following defines the version and build number for your application. 5 | # A version number is three numbers separated by dots, like 1.2.43 6 | # followed by an optional build number separated by a +. 7 | # Both the version and the builder number may be overridden in flutter 8 | # build by specifying --build-name and --build-number, respectively. 9 | # In Android, build-name is used as versionName while build-number used as versionCode. 10 | # Read more about Android versioning at https://developer.android.com/studio/publish/versioning 11 | # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. 12 | # Read more about iOS versioning at 13 | # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html 14 | version: 1.1.0+1 15 | 16 | environment: 17 | sdk: ">=2.1.0 <3.0.0" 18 | 19 | dependencies: 20 | flutter: 21 | sdk: flutter 22 | 23 | # The following adds the Cupertino Icons font to your application. 24 | # Use with the CupertinoIcons class for iOS style icons. 25 | cupertino_icons: ^0.1.2 26 | flutter_sticky_header: 0.4.2 27 | flare_flutter: 2.0.3 28 | 29 | dev_dependencies: 30 | flutter_test: 31 | sdk: flutter 32 | video_player: 0.10.11+1 33 | path_provider: 34 | http: 35 | audioplayers: 0.15.1 36 | chewie: 0.9.10 37 | 38 | 39 | # For information on the generic Dart part of this file, see the 40 | # following page: https://dart.dev/tools/pub/pubspec 41 | 42 | # The following section is specific to Flutter. 43 | flutter: 44 | 45 | # The following line ensures that the Material Icons font is 46 | # included with your application, so that you can use the icons in 47 | # the material Icons class. 48 | uses-material-design: true 49 | 50 | # To add assets to your application, add an assets section, like this: 51 | assets: 52 | - assets/ 53 | - picture/ppt/ 54 | 55 | # An image asset can refer to one or more resolution-specific "variants", see 56 | # https://flutter.dev/assets-and-images/#resolution-aware. 57 | 58 | # For details regarding adding assets from package dependencies, see 59 | # https://flutter.dev/assets-and-images/#from-packages 60 | 61 | # To add custom fonts to your application, add a fonts section here, 62 | # in this "flutter" section. Each entry in this list should have a 63 | # "family" key with the font family name, and a "fonts" key with a 64 | # list giving the asset and other descriptors for the font. For 65 | # example: 66 | # fonts: 67 | # - family: Schyler 68 | # fonts: 69 | # - asset: fonts/Schyler-Regular.ttf 70 | # - asset: fonts/Schyler-Italic.ttf 71 | # style: italic 72 | # - family: Trajan Pro 73 | # fonts: 74 | # - asset: fonts/TrajanPro.ttf 75 | # - asset: fonts/TrajanPro_Bold.ttf 76 | # weight: 700 77 | # 78 | # For details regarding fonts from package dependencies, 79 | # see https://flutter.dev/custom-fonts/#from-packages 80 | -------------------------------------------------------------------------------- /test/widget_test.dart: -------------------------------------------------------------------------------- 1 | // This is a basic Flutter widget test. 2 | // 3 | // To perform an interaction with a widget in your test, use the WidgetTester 4 | // utility that Flutter provides. For example, you can send tap and scroll 5 | // gestures. You can also use WidgetTester to find child widgets in the widget 6 | // tree, read text, and verify that the values of widget properties are correct. 7 | 8 | import 'package:flutter/material.dart'; 9 | import 'package:flutter_test/flutter_test.dart'; 10 | 11 | import 'package:flutter_widget/main.dart'; 12 | 13 | void main() { 14 | testWidgets('Counter increments smoke test', (WidgetTester tester) async { 15 | // Build our app and trigger a frame. 16 | await tester.pumpWidget(MyApp()); 17 | 18 | // Verify that our counter starts at 0. 19 | expect(find.text('0'), findsOneWidget); 20 | expect(find.text('1'), findsNothing); 21 | 22 | // Tap the '+' icon and trigger a frame. 23 | await tester.tap(find.byIcon(Icons.add)); 24 | await tester.pump(); 25 | 26 | // Verify that our counter has incremented. 27 | expect(find.text('0'), findsNothing); 28 | expect(find.text('1'), findsOneWidget); 29 | }); 30 | } 31 | --------------------------------------------------------------------------------