├── ios ├── Assets │ └── .gitkeep ├── Classes │ ├── FlutterAppUpgradePlugin.h │ ├── FlutterAppUpgradePlugin.m │ └── SwiftFlutterAppUpgradePlugin.swift ├── .gitignore └── flutter_app_upgrade.podspec ├── LICENSE ├── example ├── android │ ├── settings_aar.gradle │ ├── gradle.properties │ ├── local.properties │ ├── gradle │ │ └── wrapper │ │ │ ├── gradle-wrapper.jar │ │ │ └── gradle-wrapper.properties │ ├── app │ │ ├── src │ │ │ ├── main │ │ │ │ ├── res │ │ │ │ │ ├── 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 │ │ │ │ │ └── drawable │ │ │ │ │ │ └── launch_background.xml │ │ │ │ ├── kotlin │ │ │ │ │ └── com │ │ │ │ │ │ └── flutter │ │ │ │ │ │ └── flutter_app_upgrade_example │ │ │ │ │ │ └── MainActivity.kt │ │ │ │ ├── java │ │ │ │ │ └── io │ │ │ │ │ │ └── flutter │ │ │ │ │ │ └── plugins │ │ │ │ │ │ └── GeneratedPluginRegistrant.java │ │ │ │ └── AndroidManifest.xml │ │ │ ├── debug │ │ │ │ └── AndroidManifest.xml │ │ │ └── profile │ │ │ │ └── AndroidManifest.xml │ │ └── build.gradle │ ├── settings.gradle │ ├── build.gradle │ ├── gradlew.bat │ └── gradlew ├── ios │ ├── Runner │ │ ├── Runner-Bridging-Header.h │ │ ├── Assets.xcassets │ │ │ ├── LaunchImage.imageset │ │ │ │ ├── LaunchImage.png │ │ │ │ ├── LaunchImage@2x.png │ │ │ │ ├── LaunchImage@3x.png │ │ │ │ ├── README.md │ │ │ │ └── Contents.json │ │ │ └── AppIcon.appiconset │ │ │ │ ├── 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-1024x1024@1x.png │ │ │ │ ├── Icon-App-83.5x83.5@2x.png │ │ │ │ └── Contents.json │ │ ├── AppDelegate.swift │ │ ├── Base.lproj │ │ │ ├── Main.storyboard │ │ │ └── LaunchScreen.storyboard │ │ └── Info.plist │ ├── Flutter │ │ ├── Debug.xcconfig │ │ ├── Release.xcconfig │ │ └── AppFrameworkInfo.plist │ ├── Runner.xcodeproj │ │ ├── project.xcworkspace │ │ │ └── contents.xcworkspacedata │ │ ├── xcshareddata │ │ │ └── xcschemes │ │ │ │ └── Runner.xcscheme │ │ └── project.pbxproj │ ├── Runner.xcworkspace │ │ └── contents.xcworkspacedata │ ├── Podfile.lock │ ├── .gitignore │ └── Podfile ├── .flutter-plugins ├── .flutter-plugins-dependencies ├── test │ └── widget_test.dart ├── pubspec.yaml └── lib │ └── main.dart ├── android ├── settings.gradle ├── .gitignore ├── gradle.properties ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── src │ └── main │ │ ├── res │ │ └── xml │ │ │ └── file_paths.xml │ │ ├── AndroidManifest.xml │ │ └── kotlin │ │ └── com │ │ └── flutter │ │ └── flutter_app_upgrade │ │ └── FlutterAppUpgradePlugin.kt ├── build.gradle ├── gradlew.bat └── gradlew ├── lib ├── flutter_app_upgrade.dart └── src │ ├── download_status.dart │ ├── flutter_upgrade.dart │ ├── app_market.dart │ ├── wave.dart │ ├── liquid_progress_indicator.dart │ ├── app_upgrade.dart │ └── simple_app_upgrade.dart ├── CHANGELOG.md ├── .gitignore ├── pubspec.yaml └── README.md /ios/Assets/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | TODO: Add your license here. 2 | -------------------------------------------------------------------------------- /example/android/settings_aar.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | -------------------------------------------------------------------------------- /android/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'flutter_app_upgrade' 2 | -------------------------------------------------------------------------------- /example/ios/Runner/Runner-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | #import "GeneratedPluginRegistrant.h" -------------------------------------------------------------------------------- /android/.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | -------------------------------------------------------------------------------- /android/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx1536M 2 | android.enableR8=true 3 | android.useAndroidX=true 4 | android.enableJetifier=true 5 | -------------------------------------------------------------------------------- /example/ios/Flutter/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" 2 | #include "Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /ios/Classes/FlutterAppUpgradePlugin.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface FlutterAppUpgradePlugin : NSObject 4 | @end 5 | -------------------------------------------------------------------------------- /android/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaoMengFlutter/flutter-app-upgrade/HEAD/android/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /example/android/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx1536M 2 | android.enableR8=true 3 | android.useAndroidX=true 4 | android.enableJetifier=true 5 | -------------------------------------------------------------------------------- /example/android/local.properties: -------------------------------------------------------------------------------- 1 | sdk.dir=/Users/mengqingdong/Library/Android/sdk 2 | flutter.sdk=/Users/mengqingdong/flutter 3 | flutter.buildMode=debug -------------------------------------------------------------------------------- /example/ios/Flutter/Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" 2 | #include "Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /example/android/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaoMengFlutter/flutter-app-upgrade/HEAD/example/android/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /example/.flutter-plugins: -------------------------------------------------------------------------------- 1 | # This is a generated file; do not edit or check into version control. 2 | flutter_app_upgrade=/Users/mengqingdong/project/flutter-do/flutter_app_upgrade/ 3 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaoMengFlutter/flutter-app-upgrade/HEAD/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaoMengFlutter/flutter-app-upgrade/HEAD/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaoMengFlutter/flutter-app-upgrade/HEAD/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaoMengFlutter/flutter-app-upgrade/HEAD/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaoMengFlutter/flutter-app-upgrade/HEAD/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaoMengFlutter/flutter-app-upgrade/HEAD/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png -------------------------------------------------------------------------------- /android/src/main/res/xml/file_paths.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaoMengFlutter/flutter-app-upgrade/HEAD/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaoMengFlutter/flutter-app-upgrade/HEAD/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png -------------------------------------------------------------------------------- /lib/flutter_app_upgrade.dart: -------------------------------------------------------------------------------- 1 | 2 | 3 | library flutter_app_upgrade; 4 | 5 | export 'src/app_upgrade.dart'; 6 | export 'src/flutter_upgrade.dart'; 7 | export 'src/app_market.dart'; 8 | export 'src/download_status.dart'; -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaoMengFlutter/flutter-app-upgrade/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaoMengFlutter/flutter-app-upgrade/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaoMengFlutter/flutter-app-upgrade/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaoMengFlutter/flutter-app-upgrade/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaoMengFlutter/flutter-app-upgrade/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaoMengFlutter/flutter-app-upgrade/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaoMengFlutter/flutter-app-upgrade/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaoMengFlutter/flutter-app-upgrade/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaoMengFlutter/flutter-app-upgrade/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaoMengFlutter/flutter-app-upgrade/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaoMengFlutter/flutter-app-upgrade/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaoMengFlutter/flutter-app-upgrade/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaoMengFlutter/flutter-app-upgrade/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaoMengFlutter/flutter-app-upgrade/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaoMengFlutter/flutter-app-upgrade/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png -------------------------------------------------------------------------------- /example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | zipStoreBase=GRADLE_USER_HOME 4 | zipStorePath=wrapper/dists 5 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip 6 | -------------------------------------------------------------------------------- /example/android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Fri Jun 23 08:50:38 CEST 2017 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip 7 | -------------------------------------------------------------------------------- /android/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /example/ios/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## [1.0.0] Flutter App Upgrade 2 | 3 | * Flutter app 升级功能,支持Android和iOS。 4 | 5 | ## [1.0.2] 6 | 7 | * 修复bug。 8 | 9 | ## [1.1.0] 10 | 11 | * 1、修复一些情况下无法弹出提示框的bug。 12 | * 2、修复Android 平台弹出升级框后,点击返回键,升级框消失bug。 13 | * 3、下载完成后关闭升级框。 14 | * 4、修复多次点击“立即更新”重复下载bug。 15 | * 5、新增点击取消和立即更新按钮回调。 16 | * 6、新增下载进度和下载状态变化回调。 -------------------------------------------------------------------------------- /lib/src/download_status.dart: -------------------------------------------------------------------------------- 1 | 2 | enum DownloadStatus{ 3 | /// 4 | /// 未下载 5 | /// 6 | none, 7 | /// 8 | /// 准备开始下载,请求网络到下载第1个字节之间 9 | /// 10 | start, 11 | /// 12 | /// 正在下载 13 | /// 14 | downloading, 15 | /// 16 | /// 下载完成 17 | /// 18 | done, 19 | /// 20 | /// 下载异常 21 | /// 22 | error 23 | } -------------------------------------------------------------------------------- /example/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. -------------------------------------------------------------------------------- /example/android/app/src/debug/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /example/android/app/src/profile/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 9 | -------------------------------------------------------------------------------- /example/ios/Runner/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | import UIKit 2 | import Flutter 3 | 4 | @UIApplicationMain 5 | @objc class AppDelegate: FlutterAppDelegate { 6 | override func application( 7 | _ application: UIApplication, 8 | didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? 9 | ) -> Bool { 10 | GeneratedPluginRegistrant.register(with: self) 11 | return super.application(application, didFinishLaunchingWithOptions: launchOptions) 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/drawable/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /example/.flutter-plugins-dependencies: -------------------------------------------------------------------------------- 1 | {"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"flutter_app_upgrade","path":"/Users/mengqingdong/project/flutter-do/flutter_app_upgrade/","dependencies":[]}],"android":[{"name":"flutter_app_upgrade","path":"/Users/mengqingdong/project/flutter-do/flutter_app_upgrade/","dependencies":[]}],"macos":[],"linux":[],"windows":[],"web":[]},"dependencyGraph":[{"name":"flutter_app_upgrade","dependencies":[]}],"date_created":"2020-06-18 22:05:18.814405","version":"1.17.0"} -------------------------------------------------------------------------------- /example/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 | -------------------------------------------------------------------------------- /example/android/app/src/main/kotlin/com/flutter/flutter_app_upgrade_example/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.flutter.flutter_app_upgrade_example 2 | 3 | import androidx.annotation.NonNull; 4 | import io.flutter.embedding.android.FlutterActivity 5 | import io.flutter.embedding.engine.FlutterEngine 6 | import io.flutter.plugins.GeneratedPluginRegistrant 7 | 8 | class MainActivity: FlutterActivity() { 9 | override fun configureFlutterEngine(@NonNull flutterEngine: FlutterEngine) { 10 | GeneratedPluginRegistrant.registerWith(flutterEngine); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /example/android/settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | 3 | def flutterProjectRoot = rootProject.projectDir.parentFile.toPath() 4 | 5 | def plugins = new Properties() 6 | def pluginsFile = new File(flutterProjectRoot.toFile(), '.flutter-plugins') 7 | if (pluginsFile.exists()) { 8 | pluginsFile.withReader('UTF-8') { reader -> plugins.load(reader) } 9 | } 10 | 11 | plugins.each { name, path -> 12 | def pluginDirectory = flutterProjectRoot.resolve(path).resolve('android').toFile() 13 | include ":$name" 14 | project(":$name").projectDir = pluginDirectory 15 | } 16 | -------------------------------------------------------------------------------- /ios/.gitignore: -------------------------------------------------------------------------------- 1 | .idea/ 2 | .vagrant/ 3 | .sconsign.dblite 4 | .svn/ 5 | 6 | .DS_Store 7 | *.swp 8 | profile 9 | 10 | DerivedData/ 11 | build/ 12 | GeneratedPluginRegistrant.h 13 | GeneratedPluginRegistrant.m 14 | 15 | .generated/ 16 | 17 | *.pbxuser 18 | *.mode1v3 19 | *.mode2v3 20 | *.perspectivev3 21 | 22 | !default.pbxuser 23 | !default.mode1v3 24 | !default.mode2v3 25 | !default.perspectivev3 26 | 27 | xcuserdata 28 | 29 | *.moved-aside 30 | 31 | *.pyc 32 | *sync/ 33 | Icon? 34 | .tags* 35 | 36 | /Flutter/Generated.xcconfig 37 | /Flutter/flutter_export_environment.sh -------------------------------------------------------------------------------- /example/ios/Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - Flutter (1.0.0) 3 | - flutter_app_upgrade (0.0.1): 4 | - Flutter 5 | 6 | DEPENDENCIES: 7 | - Flutter (from `Flutter`) 8 | - flutter_app_upgrade (from `.symlinks/plugins/flutter_app_upgrade/ios`) 9 | 10 | EXTERNAL SOURCES: 11 | Flutter: 12 | :path: Flutter 13 | flutter_app_upgrade: 14 | :path: ".symlinks/plugins/flutter_app_upgrade/ios" 15 | 16 | SPEC CHECKSUMS: 17 | Flutter: 0e3d915762c693b495b44d77113d4970485de6ec 18 | flutter_app_upgrade: a62fbe2a09a2176a7b44211c8355adfcfb969779 19 | 20 | PODFILE CHECKSUM: 1b66dae606f75376c5f2135a8290850eeb09ae83 21 | 22 | COCOAPODS: 1.9.1 23 | -------------------------------------------------------------------------------- /example/android/app/src/main/java/io/flutter/plugins/GeneratedPluginRegistrant.java: -------------------------------------------------------------------------------- 1 | package io.flutter.plugins; 2 | 3 | import androidx.annotation.Keep; 4 | import androidx.annotation.NonNull; 5 | 6 | import io.flutter.embedding.engine.FlutterEngine; 7 | 8 | /** 9 | * Generated file. Do not edit. 10 | * This file is generated by the Flutter tool based on the 11 | * plugins that support the Android platform. 12 | */ 13 | @Keep 14 | public final class GeneratedPluginRegistrant { 15 | public static void registerWith(@NonNull FlutterEngine flutterEngine) { 16 | flutterEngine.getPlugins().add(new com.flutter.flutter_app_upgrade.FlutterAppUpgradePlugin()); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /example/ios/.gitignore: -------------------------------------------------------------------------------- 1 | *.mode1v3 2 | *.mode2v3 3 | *.moved-aside 4 | *.pbxuser 5 | *.perspectivev3 6 | **/*sync/ 7 | .sconsign.dblite 8 | .tags* 9 | **/.vagrant/ 10 | **/DerivedData/ 11 | Icon? 12 | **/Pods/ 13 | **/.symlinks/ 14 | profile 15 | xcuserdata 16 | **/.generated/ 17 | Flutter/App.framework 18 | Flutter/Flutter.framework 19 | Flutter/Flutter.podspec 20 | Flutter/Generated.xcconfig 21 | Flutter/app.flx 22 | Flutter/app.zip 23 | Flutter/flutter_assets/ 24 | Flutter/flutter_export_environment.sh 25 | ServiceDefinitions.json 26 | Runner/GeneratedPluginRegistrant.* 27 | 28 | # Exceptions to above rules. 29 | !default.mode1v3 30 | !default.mode2v3 31 | !default.pbxuser 32 | !default.perspectivev3 33 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://www.dartlang.org/guides/libraries/private-files 2 | 3 | # Files and directories created by pub 4 | .dart_tool/ 5 | .packages 6 | build/ 7 | # If you're building an application, you may want to check-in your pubspec.lock 8 | pubspec.lock 9 | 10 | # Directory created by dartdoc 11 | # If you don't generate documentation locally you can remove this line. 12 | doc/api/ 13 | 14 | # Avoid committing generated Javascript files: 15 | *.dart.js 16 | *.info.json # Produced by the --dump-info flag. 17 | *.js # When generated by dart2js. Don't specify *.js if your 18 | # project includes source files written in JavaScript. 19 | *.js_ 20 | *.js.deps 21 | *.js.map 22 | -------------------------------------------------------------------------------- /ios/Classes/FlutterAppUpgradePlugin.m: -------------------------------------------------------------------------------- 1 | #import "FlutterAppUpgradePlugin.h" 2 | #if __has_include() 3 | #import 4 | #else 5 | // Support project import fallback if the generated compatibility header 6 | // is not copied when this plugin is created as a library. 7 | // https://forums.swift.org/t/swift-static-libraries-dont-copy-generated-objective-c-header/19816 8 | #import "flutter_app_upgrade-Swift.h" 9 | #endif 10 | 11 | @implementation FlutterAppUpgradePlugin 12 | + (void)registerWithRegistrar:(NSObject*)registrar { 13 | [SwiftFlutterAppUpgradePlugin registerWithRegistrar:registrar]; 14 | } 15 | @end 16 | -------------------------------------------------------------------------------- /example/android/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | ext.kotlin_version = '1.3.50' 3 | repositories { 4 | google() 5 | jcenter() 6 | } 7 | 8 | dependencies { 9 | classpath 'com.android.tools.build:gradle:3.5.0' 10 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 11 | } 12 | } 13 | 14 | allprojects { 15 | repositories { 16 | google() 17 | jcenter() 18 | } 19 | } 20 | 21 | rootProject.buildDir = '../build' 22 | subprojects { 23 | project.buildDir = "${rootProject.buildDir}/${project.name}" 24 | } 25 | subprojects { 26 | project.evaluationDependsOn(':app') 27 | } 28 | 29 | task clean(type: Delete) { 30 | delete rootProject.buildDir 31 | } 32 | -------------------------------------------------------------------------------- /example/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_app_upgrade.podspec: -------------------------------------------------------------------------------- 1 | # 2 | # To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html. 3 | # Run `pod lib lint flutter_app_upgrade.podspec' to validate before publishing. 4 | # 5 | Pod::Spec.new do |s| 6 | s.name = 'flutter_app_upgrade' 7 | s.version = '0.0.1' 8 | s.summary = 'app upgrade' 9 | s.description = <<-DESC 10 | app upgrade 11 | DESC 12 | s.homepage = 'http://example.com' 13 | s.license = { :file => '../LICENSE' } 14 | s.author = { 'Your Company' => 'email@example.com' } 15 | s.source = { :path => '.' } 16 | s.source_files = 'Classes/**/*' 17 | s.dependency 'Flutter' 18 | s.platform = :ios, '8.0' 19 | 20 | # Flutter.framework does not contain a i386 slice. Only x86_64 simulators are supported. 21 | s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'VALID_ARCHS[sdk=iphonesimulator*]' => 'x86_64' } 22 | s.swift_version = '5.0' 23 | end 24 | -------------------------------------------------------------------------------- /example/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_app_upgrade_example/main.dart'; 12 | 13 | void main() { 14 | testWidgets('Verify Platform version', (WidgetTester tester) async { 15 | // Build our app and trigger a frame. 16 | await tester.pumpWidget(MyApp()); 17 | 18 | // Verify that platform version is retrieved. 19 | expect( 20 | find.byWidgetPredicate( 21 | (Widget widget) => widget is Text && 22 | widget.data.startsWith('Running on:'), 23 | ), 24 | findsOneWidget, 25 | ); 26 | }); 27 | } 28 | -------------------------------------------------------------------------------- /android/build.gradle: -------------------------------------------------------------------------------- 1 | group 'com.flutter.flutter_app_upgrade' 2 | version '1.0-SNAPSHOT' 3 | 4 | buildscript { 5 | ext.kotlin_version = '1.3.50' 6 | repositories { 7 | google() 8 | jcenter() 9 | } 10 | 11 | dependencies { 12 | classpath 'com.android.tools.build:gradle:3.5.0' 13 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 14 | } 15 | } 16 | 17 | rootProject.allprojects { 18 | repositories { 19 | google() 20 | jcenter() 21 | } 22 | } 23 | 24 | apply plugin: 'com.android.library' 25 | apply plugin: 'kotlin-android' 26 | 27 | android { 28 | compileSdkVersion 28 29 | 30 | sourceSets { 31 | main.java.srcDirs += 'src/main/kotlin' 32 | } 33 | defaultConfig { 34 | minSdkVersion 16 35 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 36 | } 37 | lintOptions { 38 | disable 'InvalidPackage' 39 | } 40 | } 41 | 42 | dependencies { 43 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" 44 | } 45 | -------------------------------------------------------------------------------- /example/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 | -------------------------------------------------------------------------------- /example/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_app_upgrade_example 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | $(FLUTTER_BUILD_NAME) 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | $(FLUTTER_BUILD_NUMBER) 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UISupportedInterfaceOrientations 30 | 31 | UIInterfaceOrientationPortrait 32 | UIInterfaceOrientationLandscapeLeft 33 | UIInterfaceOrientationLandscapeRight 34 | 35 | UISupportedInterfaceOrientations~ipad 36 | 37 | UIInterfaceOrientationPortrait 38 | UIInterfaceOrientationPortraitUpsideDown 39 | UIInterfaceOrientationLandscapeLeft 40 | UIInterfaceOrientationLandscapeRight 41 | 42 | UIViewControllerBasedStatusBarAppearance 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /ios/Classes/SwiftFlutterAppUpgradePlugin.swift: -------------------------------------------------------------------------------- 1 | import Flutter 2 | import UIKit 3 | 4 | public class SwiftFlutterAppUpgradePlugin: NSObject, FlutterPlugin { 5 | public static func register(with registrar: FlutterPluginRegistrar) { 6 | let channel = FlutterMethodChannel(name: "flutter_app_upgrade", binaryMessenger: registrar.messenger()) 7 | let instance = SwiftFlutterAppUpgradePlugin() 8 | registrar.addMethodCallDelegate(instance, channel: channel) 9 | } 10 | 11 | public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) { 12 | if (call.method == "getAppInfo") { 13 | let infoDictionary = Bundle.main.infoDictionary! 14 | let majorVersion = infoDictionary["CFBundleShortVersionString"]//主程序版本号 15 | let bundleIdentifier = infoDictionary["CFBundleIdentifier"] 16 | var map = [String:String]() 17 | map["packageName"] = bundleIdentifier as! String 18 | map["versionName"] = majorVersion as! String 19 | map["versionCode"] = "0" 20 | result(map) 21 | }else if(call.method == "toAppStore"){ 22 | let args = call.arguments as! Dictionary 23 | let urlString = "itms-apps://itunes.apple.com/app/"+(args["id"] ?? "") 24 | if let url = URL(string: urlString) { 25 | //根据iOS系统版本,分别处理 26 | if #available(iOS 10, *) { 27 | UIApplication.shared.open(url, options: [:], 28 | completionHandler: { 29 | (success) in 30 | }) 31 | } else { 32 | UIApplication.shared.openURL(url) 33 | } 34 | } 35 | } 36 | 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: flutter_app_upgrade 2 | description: App 升级功能 3 | version: 1.1.0 4 | homepage: http://laomengit.com/plugin/upgrade.html 5 | 6 | environment: 7 | sdk: ">=2.1.0 <3.0.0" 8 | 9 | dependencies: 10 | flutter: 11 | sdk: flutter 12 | 13 | dio: ^3.0.9 14 | 15 | dev_dependencies: 16 | flutter_test: 17 | sdk: flutter 18 | 19 | # For information on the generic Dart part of this file, see the 20 | # following page: https://dart.dev/tools/pub/pubspec 21 | 22 | # The following section is specific to Flutter. 23 | flutter: 24 | # This section identifies this Flutter project as a plugin project. 25 | # The androidPackage and pluginClass identifiers should not ordinarily 26 | # be modified. They are used by the tooling to maintain consistency when 27 | # adding or updating assets for this project. 28 | plugin: 29 | androidPackage: com.flutter.flutter_app_upgrade 30 | pluginClass: FlutterAppUpgradePlugin 31 | 32 | # To add assets to your plugin package, add an assets section, like this: 33 | # assets: 34 | # - images/a_dot_burr.jpeg 35 | # - images/a_dot_ham.jpeg 36 | # 37 | # For details regarding assets in packages, see 38 | # https://flutter.dev/assets-and-images/#from-packages 39 | # 40 | # An image asset can refer to one or more resolution-specific "variants", see 41 | # https://flutter.dev/assets-and-images/#resolution-aware. 42 | 43 | # To add custom fonts to your plugin package, add a fonts section here, 44 | # in this "flutter" section. Each entry in this list should have a 45 | # "family" key with the font family name, and a "fonts" key with a 46 | # list giving the asset and other descriptors for the font. For 47 | # example: 48 | # fonts: 49 | # - family: Schyler 50 | # fonts: 51 | # - asset: fonts/Schyler-Regular.ttf 52 | # - asset: fonts/Schyler-Italic.ttf 53 | # style: italic 54 | # - family: Trajan Pro 55 | # fonts: 56 | # - asset: fonts/TrajanPro.ttf 57 | # - asset: fonts/TrajanPro_Bold.ttf 58 | # weight: 700 59 | # 60 | # For details regarding fonts in packages, see 61 | # https://flutter.dev/custom-fonts/#from-packages 62 | -------------------------------------------------------------------------------- /lib/src/flutter_upgrade.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | 3 | import 'package:flutter/services.dart'; 4 | import 'package:flutter_app_upgrade/flutter_app_upgrade.dart'; 5 | 6 | class FlutterUpgrade { 7 | static const MethodChannel _channel = const MethodChannel('flutter_app_upgrade'); 8 | 9 | /// 10 | /// 获取app信息 11 | /// 12 | static Future get appInfo async { 13 | var result = await _channel.invokeMethod('getAppInfo'); 14 | return AppInfo( 15 | versionName: result['versionName'], 16 | versionCode: result['versionCode'], 17 | packageName: result['packageName']); 18 | } 19 | 20 | /// 21 | /// 获取apk下载路径 22 | /// 23 | static Future get apkDownloadPath async { 24 | return await _channel.invokeMethod('getApkDownloadPath'); 25 | } 26 | 27 | /// 28 | /// Android 安装app 29 | /// 30 | static installAppForAndroid(String path) async { 31 | var map = {'path': path}; 32 | return await _channel.invokeMethod('install', map); 33 | } 34 | 35 | /// 36 | /// 跳转到ios app store 37 | /// 38 | static toAppStore(String id) async { 39 | var map = {'id': id}; 40 | return await _channel.invokeMethod('toAppStore', map); 41 | } 42 | 43 | /// 44 | /// 获取android手机上安装的应用商店 45 | /// 46 | static getInstallMarket({List marketPackageNames}) async { 47 | List packageNameList = AppMarket.buildInPackageNameList; 48 | if (marketPackageNames != null && marketPackageNames.length > 0) { 49 | packageNameList.addAll(marketPackageNames); 50 | } 51 | var map = {'packages': packageNameList}; 52 | var result = await _channel.invokeMethod('getInstallMarket', map); 53 | List resultList = (result as List).map((f) { 54 | return '$f'; 55 | }).toList(); 56 | return resultList; 57 | } 58 | 59 | /// 60 | /// 跳转到应用商店 61 | /// 62 | static toMarket({AppMarketInfo appMarketInfo}) async { 63 | var map = { 64 | 'marketPackageName': 65 | appMarketInfo != null ? appMarketInfo.packageName : '', 66 | 'marketClassName': appMarketInfo != null ? appMarketInfo.className : '' 67 | }; 68 | return await _channel.invokeMethod('toMarket', map); 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /example/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: flutter_app_upgrade_example 2 | description: Demonstrates how to use the flutter_app_upgrade plugin. 3 | publish_to: 'none' 4 | 5 | environment: 6 | sdk: ">=2.1.0 <3.0.0" 7 | 8 | dependencies: 9 | flutter: 10 | sdk: flutter 11 | 12 | # The following adds the Cupertino Icons font to your application. 13 | # Use with the CupertinoIcons class for iOS style icons. 14 | cupertino_icons: ^0.1.2 15 | 16 | dev_dependencies: 17 | flutter_test: 18 | sdk: flutter 19 | 20 | flutter_app_upgrade: 21 | path: ../ 22 | 23 | # For information on the generic Dart part of this file, see the 24 | # following page: https://dart.dev/tools/pub/pubspec 25 | 26 | # The following section is specific to Flutter. 27 | flutter: 28 | 29 | # The following line ensures that the Material Icons font is 30 | # included with your application, so that you can use the icons in 31 | # the material Icons class. 32 | uses-material-design: true 33 | 34 | # To add assets to your application, add an assets section, like this: 35 | # assets: 36 | # - images/a_dot_burr.jpeg 37 | # - images/a_dot_ham.jpeg 38 | 39 | # An image asset can refer to one or more resolution-specific "variants", see 40 | # https://flutter.dev/assets-and-images/#resolution-aware. 41 | 42 | # For details regarding adding assets from package dependencies, see 43 | # https://flutter.dev/assets-and-images/#from-packages 44 | 45 | # To add custom fonts to your application, add a fonts section here, 46 | # in this "flutter" section. Each entry in this list should have a 47 | # "family" key with the font family name, and a "fonts" key with a 48 | # list giving the asset and other descriptors for the font. For 49 | # example: 50 | # fonts: 51 | # - family: Schyler 52 | # fonts: 53 | # - asset: fonts/Schyler-Regular.ttf 54 | # - asset: fonts/Schyler-Italic.ttf 55 | # style: italic 56 | # - family: Trajan Pro 57 | # fonts: 58 | # - asset: fonts/TrajanPro.ttf 59 | # - asset: fonts/TrajanPro_Bold.ttf 60 | # weight: 700 61 | # 62 | # For details regarding fonts from package dependencies, 63 | # see https://flutter.dev/custom-fonts/#from-packages 64 | -------------------------------------------------------------------------------- /example/android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 4 | 9 | 13 | 20 | 21 | 22 | 23 | 24 | 25 | 27 | 30 | 31 | 36 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /example/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.flutter.flutter_app_upgrade_example" 42 | minSdkVersion 16 43 | targetSdkVersion 28 44 | versionCode flutterVersionCode.toInteger() 45 | versionName flutterVersionName 46 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 47 | } 48 | 49 | buildTypes { 50 | release { 51 | // TODO: Add your own signing config for the release build. 52 | // Signing with the debug keys for now, so `flutter run --release` works. 53 | signingConfig signingConfigs.debug 54 | } 55 | } 56 | } 57 | 58 | flutter { 59 | source '../..' 60 | } 61 | 62 | dependencies { 63 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" 64 | testImplementation 'junit:junit:4.12' 65 | androidTestImplementation 'androidx.test:runner:1.1.1' 66 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1' 67 | } 68 | -------------------------------------------------------------------------------- /example/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 | -------------------------------------------------------------------------------- /android/gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /example/android/gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /example/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 | -------------------------------------------------------------------------------- /lib/src/app_market.dart: -------------------------------------------------------------------------------- 1 | /// 2 | /// des: 3 | /// 4 | 5 | class AppMarket { 6 | /// 7 | /// 获取所有内置的应用商店的包名 8 | /// 9 | static List get buildInPackageNameList { 10 | return buildInMarketList.map((f) { 11 | return f.packageName; 12 | }).toList(); 13 | } 14 | 15 | /// 16 | /// 通过包名获取内置应用商店 17 | /// 18 | static List getBuildInMarketList(List packageNames) { 19 | List marketList = []; 20 | packageNames.forEach((packageName) { 21 | buildInMarketList.forEach((f) { 22 | if (f.packageName == packageName) { 23 | marketList.add(f); 24 | } 25 | }); 26 | }); 27 | return marketList; 28 | } 29 | 30 | static AppMarketInfo getBuildInMarket(String packageName) { 31 | AppMarketInfo _info; 32 | buildInMarketList.forEach((f) { 33 | if (f.packageName == packageName) { 34 | _info = f; 35 | } 36 | }); 37 | return _info; 38 | } 39 | 40 | /// 41 | /// 获取所有内置的应用商店 42 | /// 43 | static List get buildInMarketList { 44 | return [ 45 | xiaoMi, 46 | meiZu, 47 | vivo, 48 | oppo, 49 | huaWei, 50 | zte, 51 | qiHoo, 52 | tencent, 53 | pp, 54 | wanDouJia 55 | ]; 56 | } 57 | 58 | /// 59 | /// 小米 60 | /// 61 | static final xiaoMi = AppMarketInfo( 62 | 'xiaoMi', "com.xiaomi.market", "com.xiaomi.market.ui.AppDetailActivity"); 63 | 64 | /// 65 | /// 魅族 66 | /// 67 | static final meiZu = AppMarketInfo('meiZu', "com.meizu.mstore", 68 | "com.meizu.flyme.appcenter.activitys.AppMainActivity"); 69 | 70 | /// 71 | /// vivo 72 | /// 73 | static final vivo = AppMarketInfo( 74 | 'vivo', "com.bbk.appstore", "com.bbk.appstore.ui.AppStoreTabActivity"); 75 | 76 | /// 77 | /// oppo 78 | /// 79 | static final oppo = AppMarketInfo('oppo', "com.oppo.market", "a.a.a.aoz"); 80 | 81 | /// 82 | /// 华为 83 | /// 84 | static final huaWei = AppMarketInfo('huaWei', "com.huawei.appmarket", 85 | "com.huawei.appmarket.service.externalapi.view.ThirdApiActivity"); 86 | 87 | /// 88 | /// zte 89 | /// 90 | static final zte = AppMarketInfo('zte', "zte.com.market", 91 | "zte.com.market.view.zte.drain.ZtDrainTrafficActivity"); 92 | 93 | /// 94 | /// 360 95 | /// 96 | static final qiHoo = AppMarketInfo('qiHoo', "com.qihoo.appstore", 97 | "com.qihoo.appstore.distribute.SearchDistributionActivity"); 98 | 99 | /// 100 | /// 应用宝 101 | /// 102 | static final tencent = AppMarketInfo( 103 | 'tencent', 104 | "com.tencent.android.qqdownloader", 105 | "com.tencent.pangu.link.LinkProxyActivity"); 106 | 107 | /// 108 | /// pp助手 109 | /// 110 | static final pp = AppMarketInfo( 111 | 'pp', "com.pp.assistant", "com.pp.assistant.activity.MainActivity"); 112 | 113 | /// 114 | /// 豌豆荚 115 | /// 116 | static final wanDouJia = AppMarketInfo('wanDouJia', "com.wandoujia.phoenix2", 117 | "com.pp.assistant.activity.PPMainActivity"); 118 | } 119 | 120 | class AppMarketInfo { 121 | const AppMarketInfo(this.marketName, this.packageName, this.className); 122 | 123 | final String marketName; 124 | final String packageName; 125 | final String className; 126 | } 127 | -------------------------------------------------------------------------------- /example/lib/main.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'dart:async'; 3 | import 'package:flutter_app_upgrade/flutter_app_upgrade.dart'; 4 | 5 | void main() => runApp(MyApp()); 6 | 7 | class MyApp extends StatefulWidget { 8 | @override 9 | _MyAppState createState() => _MyAppState(); 10 | } 11 | 12 | class _MyAppState extends State { 13 | @override 14 | void initState() { 15 | super.initState(); 16 | } 17 | 18 | @override 19 | Widget build(BuildContext context) { 20 | return MaterialApp( 21 | home: Scaffold( 22 | appBar: AppBar( 23 | title: const Text('App 升级测试'), 24 | ), 25 | body: Stack( 26 | children: [ 27 | Center( 28 | child: Column( 29 | children: [ 30 | Home(), 31 | ], 32 | ), 33 | ), 34 | ], 35 | ), 36 | ), 37 | ); 38 | } 39 | } 40 | 41 | class Home extends StatefulWidget { 42 | @override 43 | State createState() => _HomeState(); 44 | } 45 | 46 | class _HomeState extends State { 47 | AppInfo _appInfo; 48 | List _appMarketList = []; 49 | String _installMarkets = ''; 50 | 51 | @override 52 | void initState() { 53 | _checkAppUpgrade(); 54 | _getInstallMarket(); 55 | _getAppInfo(); 56 | super.initState(); 57 | } 58 | 59 | _checkAppUpgrade() { 60 | AppUpgrade.appUpgrade( 61 | context, 62 | _checkAppInfo(), 63 | cancelText: '以后再说', 64 | okText: '马上升级', 65 | iosAppId: 'id88888888', 66 | appMarketInfo: AppMarket.huaWei, 67 | onCancel: () { 68 | print('onCancel'); 69 | }, 70 | onOk: () { 71 | print('onOk'); 72 | }, 73 | downloadProgress: (count, total) { 74 | print('count:$count,total:$total'); 75 | }, 76 | downloadStatusChange: (DownloadStatus status, {dynamic error}) { 77 | print('status:$status,error:$error'); 78 | }, 79 | ); 80 | } 81 | 82 | Future _checkAppInfo() async { 83 | //这里一般访问网络接口,将返回的数据解析成如下格式 84 | return Future.delayed(Duration(seconds: 1), () { 85 | return AppUpgradeInfo( 86 | title: '新版本V1.1.1', 87 | contents: [ 88 | '1、支持立体声蓝牙耳机,同时改善配对性能', 89 | '2、提供屏幕虚拟键盘', 90 | '3、更简洁更流畅,使用起来更快', 91 | '4、修复一些软件在使用时自动退出bug', 92 | '5、新增加了分类查看功能' 93 | ], 94 | force: false, 95 | ); 96 | }); 97 | } 98 | 99 | _getAppInfo() async { 100 | var appInfo = await FlutterUpgrade.appInfo; 101 | setState(() { 102 | _appInfo = appInfo; 103 | }); 104 | } 105 | 106 | _getInstallMarket() async { 107 | List marketList = await FlutterUpgrade.getInstallMarket(); 108 | marketList.forEach((f) { 109 | _installMarkets += '$f,'; 110 | }); 111 | } 112 | 113 | @override 114 | Widget build(BuildContext context) { 115 | return Column( 116 | children: [ 117 | Text('packageName:${_appInfo?.packageName}'), 118 | Text('versionName:${_appInfo?.versionName}'), 119 | Text('versionCode:${_appInfo?.versionCode}'), 120 | Text('安装的应用商店:$_installMarkets'), 121 | ], 122 | ); 123 | } 124 | } -------------------------------------------------------------------------------- /lib/src/wave.dart: -------------------------------------------------------------------------------- 1 | import 'dart:math' as math; 2 | 3 | import 'package:flutter/material.dart'; 4 | 5 | class Wave extends StatefulWidget { 6 | final double value; 7 | final Color color; 8 | final Axis direction; 9 | 10 | const Wave({ 11 | Key key, 12 | @required this.value, 13 | @required this.color, 14 | @required this.direction, 15 | }) : super(key: key); 16 | 17 | @override 18 | _WaveState createState() => _WaveState(); 19 | } 20 | 21 | class _WaveState extends State with SingleTickerProviderStateMixin { 22 | AnimationController _animationController; 23 | 24 | @override 25 | void initState() { 26 | super.initState(); 27 | 28 | _animationController = AnimationController( 29 | vsync: this, 30 | duration: Duration(seconds: 2), 31 | ); 32 | _animationController.repeat(); 33 | } 34 | 35 | @override 36 | void dispose() { 37 | _animationController.dispose(); 38 | super.dispose(); 39 | } 40 | 41 | @override 42 | Widget build(BuildContext context) { 43 | return AnimatedBuilder( 44 | animation: CurvedAnimation( 45 | parent: _animationController, 46 | curve: Curves.easeInOut, 47 | ), 48 | builder: (context, child) => ClipPath( 49 | child: Container( 50 | color: widget.color, 51 | ), 52 | clipper: _WaveClipper( 53 | animationValue: _animationController.value, 54 | value: widget.value, 55 | direction: widget.direction, 56 | ), 57 | ), 58 | ); 59 | } 60 | } 61 | 62 | class _WaveClipper extends CustomClipper { 63 | final double animationValue; 64 | final double value; 65 | final Axis direction; 66 | 67 | _WaveClipper({ 68 | @required this.animationValue, 69 | @required this.value, 70 | @required this.direction, 71 | }); 72 | 73 | @override 74 | Path getClip(Size size) { 75 | if (direction == Axis.horizontal) { 76 | Path path = Path() 77 | ..addPolygon(_generateHorizontalWavePath(size), false) 78 | ..lineTo(0.0, size.height) 79 | ..lineTo(0.0, 0.0) 80 | ..close(); 81 | return path; 82 | } 83 | 84 | Path path = Path() 85 | ..addPolygon(_generateVerticalWavePath(size), false) 86 | ..lineTo(size.width, size.height) 87 | ..lineTo(0.0, size.height) 88 | ..close(); 89 | return path; 90 | } 91 | 92 | List _generateHorizontalWavePath(Size size) { 93 | final waveList = []; 94 | for (int i = -2; i <= size.height.toInt() + 2; i++) { 95 | final waveHeight = (size.width / 20); 96 | final dx = math.sin((animationValue * 360 - i) % 360 * (math.pi / 180)) * 97 | waveHeight + 98 | (size.width * value); 99 | waveList.add(Offset(dx, i.toDouble())); 100 | } 101 | return waveList; 102 | } 103 | 104 | List _generateVerticalWavePath(Size size) { 105 | final waveList = []; 106 | for (int i = -2; i <= size.width.toInt() + 2; i++) { 107 | final waveHeight = (size.height / 20); 108 | final dy = math.sin((animationValue * 360 - i) % 360 * (math.pi / 180)) * 109 | waveHeight + 110 | (size.height - (size.height * value)); 111 | waveList.add(Offset(i.toDouble(), dy)); 112 | } 113 | return waveList; 114 | } 115 | 116 | @override 117 | bool shouldReclip(_WaveClipper oldClipper) => 118 | animationValue != oldClipper.animationValue; 119 | } -------------------------------------------------------------------------------- /example/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 | -------------------------------------------------------------------------------- /example/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 parse_KV_file(file, separator='=') 14 | file_abs_path = File.expand_path(file) 15 | if !File.exists? file_abs_path 16 | return []; 17 | end 18 | generated_key_values = {} 19 | skip_line_start_symbols = ["#", "/"] 20 | File.foreach(file_abs_path) do |line| 21 | next if skip_line_start_symbols.any? { |symbol| line =~ /^\s*#{symbol}/ } 22 | plugin = line.split(pattern=separator) 23 | if plugin.length == 2 24 | podname = plugin[0].strip() 25 | path = plugin[1].strip() 26 | podpath = File.expand_path("#{path}", file_abs_path) 27 | generated_key_values[podname] = podpath 28 | else 29 | puts "Invalid plugin specification: #{line}" 30 | end 31 | end 32 | generated_key_values 33 | end 34 | 35 | target 'Runner' do 36 | use_frameworks! 37 | use_modular_headers! 38 | 39 | # Flutter Pod 40 | 41 | copied_flutter_dir = File.join(__dir__, 'Flutter') 42 | copied_framework_path = File.join(copied_flutter_dir, 'Flutter.framework') 43 | copied_podspec_path = File.join(copied_flutter_dir, 'Flutter.podspec') 44 | unless File.exist?(copied_framework_path) && File.exist?(copied_podspec_path) 45 | # Copy Flutter.framework and Flutter.podspec to Flutter/ to have something to link against if the xcode backend script has not run yet. 46 | # That script will copy the correct debug/profile/release version of the framework based on the currently selected Xcode configuration. 47 | # CocoaPods will not embed the framework on pod install (before any build phases can generate) if the dylib does not exist. 48 | 49 | generated_xcode_build_settings_path = File.join(copied_flutter_dir, 'Generated.xcconfig') 50 | unless File.exist?(generated_xcode_build_settings_path) 51 | raise "Generated.xcconfig must exist. If you're running pod install manually, make sure flutter pub get is executed first" 52 | end 53 | generated_xcode_build_settings = parse_KV_file(generated_xcode_build_settings_path) 54 | cached_framework_dir = generated_xcode_build_settings['FLUTTER_FRAMEWORK_DIR']; 55 | 56 | unless File.exist?(copied_framework_path) 57 | FileUtils.cp_r(File.join(cached_framework_dir, 'Flutter.framework'), copied_flutter_dir) 58 | end 59 | unless File.exist?(copied_podspec_path) 60 | FileUtils.cp(File.join(cached_framework_dir, 'Flutter.podspec'), copied_flutter_dir) 61 | end 62 | end 63 | 64 | # Keep pod path relative so it can be checked into Podfile.lock. 65 | pod 'Flutter', :path => 'Flutter' 66 | 67 | # Plugin Pods 68 | 69 | # Prepare symlinks folder. We use symlinks to avoid having Podfile.lock 70 | # referring to absolute paths on developers' machines. 71 | system('rm -rf .symlinks') 72 | system('mkdir -p .symlinks/plugins') 73 | plugin_pods = parse_KV_file('../.flutter-plugins') 74 | plugin_pods.each do |name, path| 75 | symlink = File.join('.symlinks', 'plugins', name) 76 | File.symlink(path, symlink) 77 | pod name, :path => File.join(symlink, 'ios') 78 | end 79 | end 80 | 81 | # Prevent Cocoapods from embedding a second Flutter framework and causing an error with the new Xcode build system. 82 | install! 'cocoapods', :disable_input_output_paths => true 83 | 84 | post_install do |installer| 85 | installer.pods_project.targets.each do |target| 86 | target.build_configurations.each do |config| 87 | config.build_settings['ENABLE_BITCODE'] = 'NO' 88 | end 89 | end 90 | end 91 | -------------------------------------------------------------------------------- /lib/src/liquid_progress_indicator.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_app_upgrade/src/wave.dart'; 3 | 4 | class LiquidLinearProgressIndicator extends ProgressIndicator { 5 | ///The width of the border, if this is set [borderColor] must also be set. 6 | final double borderWidth; 7 | 8 | ///The color of the border, if this is set [borderWidth] must also be set. 9 | final Color borderColor; 10 | 11 | ///The radius of the border. 12 | final double borderRadius; 13 | 14 | ///The widget to show in the center of the progress indicator. 15 | final Widget center; 16 | 17 | ///The direction the liquid travels. 18 | final Axis direction; 19 | 20 | LiquidLinearProgressIndicator({ 21 | Key key, 22 | double value = 0.5, 23 | Color backgroundColor, 24 | Animation valueColor, 25 | this.borderWidth, 26 | this.borderColor, 27 | this.borderRadius, 28 | this.center, 29 | this.direction = Axis.horizontal, 30 | }) : super( 31 | key: key, 32 | value: value, 33 | backgroundColor: backgroundColor, 34 | valueColor: valueColor, 35 | ) { 36 | if (borderWidth != null && borderColor == null || 37 | borderColor != null && borderWidth == null) { 38 | throw ArgumentError("borderWidth and borderColor should both be set."); 39 | } 40 | } 41 | 42 | Color _getBackgroundColor(BuildContext context) => 43 | backgroundColor ?? Color(0x0000BFFF); //Theme.of(context).backgroundColor; 44 | 45 | Color _getValueColor(BuildContext context) => 46 | valueColor?.value ?? Color(0x6600BFFF); //Theme.of(context).accentColor; 47 | 48 | @override 49 | State createState() => _LiquidLinearProgressIndicatorState(); 50 | } 51 | 52 | class _LiquidLinearProgressIndicatorState 53 | extends State { 54 | @override 55 | Widget build(BuildContext context) { 56 | return ClipPath( 57 | clipper: _LinearClipper( 58 | radius: widget.borderRadius, 59 | ), 60 | child: CustomPaint( 61 | painter: _LinearPainter( 62 | color: widget._getBackgroundColor(context), 63 | radius: widget.borderRadius, 64 | ), 65 | foregroundPainter: _LinearBorderPainter( 66 | color: widget.borderColor, 67 | width: widget.borderWidth, 68 | radius: widget.borderRadius, 69 | ), 70 | child: Stack( 71 | children: [ 72 | Wave( 73 | value: widget.value, 74 | color: widget._getValueColor(context), 75 | direction: widget.direction, 76 | ), 77 | widget.center != null ? Center(child: widget.center) : Container(), 78 | ], 79 | ), 80 | ), 81 | ); 82 | } 83 | } 84 | 85 | class _LinearPainter extends CustomPainter { 86 | final Color color; 87 | final double radius; 88 | 89 | _LinearPainter({@required this.color, @required this.radius}); 90 | 91 | @override 92 | void paint(Canvas canvas, Size size) { 93 | final paint = Paint()..color = color; 94 | canvas.drawRRect( 95 | RRect.fromRectAndRadius( 96 | Rect.fromLTWH(0, 0, size.width, size.height), 97 | Radius.circular(radius ?? 0), 98 | ), 99 | paint); 100 | } 101 | 102 | @override 103 | bool shouldRepaint(_LinearPainter oldDelegate) => color != oldDelegate.color; 104 | } 105 | 106 | class _LinearBorderPainter extends CustomPainter { 107 | final Color color; 108 | final double width; 109 | final double radius; 110 | 111 | _LinearBorderPainter({ 112 | @required this.color, 113 | @required this.width, 114 | @required this.radius, 115 | }); 116 | 117 | @override 118 | void paint(Canvas canvas, Size size) { 119 | if (color == null || width == null) { 120 | return; 121 | } 122 | 123 | final paint = Paint() 124 | ..color = color 125 | ..style = PaintingStyle.stroke 126 | ..strokeWidth = width; 127 | final alteredRadius = radius ?? 0; 128 | canvas.drawRRect( 129 | RRect.fromRectAndRadius( 130 | Rect.fromLTWH( 131 | width / 2, width / 2, size.width - width, size.height - width), 132 | Radius.circular(alteredRadius - width ?? 0), 133 | ), 134 | paint); 135 | } 136 | 137 | @override 138 | bool shouldRepaint(_LinearBorderPainter oldDelegate) => 139 | color != oldDelegate.color || 140 | width != oldDelegate.width || 141 | radius != oldDelegate.radius; 142 | } 143 | 144 | class _LinearClipper extends CustomClipper { 145 | final double radius; 146 | 147 | _LinearClipper({@required this.radius}); 148 | 149 | @override 150 | Path getClip(Size size) { 151 | final path = Path() 152 | ..addRRect( 153 | RRect.fromRectAndRadius( 154 | Rect.fromLTWH(0, 0, size.width, size.height), 155 | Radius.circular(radius ?? 0), 156 | ), 157 | ); 158 | return path; 159 | } 160 | 161 | @override 162 | bool shouldReclip(CustomClipper oldClipper) => false; 163 | } 164 | -------------------------------------------------------------------------------- /android/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # Attempt to set APP_HOME 46 | # Resolve links: $0 may be a link 47 | PRG="$0" 48 | # Need this for relative symlinks. 49 | while [ -h "$PRG" ] ; do 50 | ls=`ls -ld "$PRG"` 51 | link=`expr "$ls" : '.*-> \(.*\)$'` 52 | if expr "$link" : '/.*' > /dev/null; then 53 | PRG="$link" 54 | else 55 | PRG=`dirname "$PRG"`"/$link" 56 | fi 57 | done 58 | SAVED="`pwd`" 59 | cd "`dirname \"$PRG\"`/" >/dev/null 60 | APP_HOME="`pwd -P`" 61 | cd "$SAVED" >/dev/null 62 | 63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 64 | 65 | # Determine the Java command to use to start the JVM. 66 | if [ -n "$JAVA_HOME" ] ; then 67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 68 | # IBM's JDK on AIX uses strange locations for the executables 69 | JAVACMD="$JAVA_HOME/jre/sh/java" 70 | else 71 | JAVACMD="$JAVA_HOME/bin/java" 72 | fi 73 | if [ ! -x "$JAVACMD" ] ; then 74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 75 | 76 | Please set the JAVA_HOME variable in your environment to match the 77 | location of your Java installation." 78 | fi 79 | else 80 | JAVACMD="java" 81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 82 | 83 | Please set the JAVA_HOME variable in your environment to match the 84 | location of your Java installation." 85 | fi 86 | 87 | # Increase the maximum file descriptors if we can. 88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 89 | MAX_FD_LIMIT=`ulimit -H -n` 90 | if [ $? -eq 0 ] ; then 91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 92 | MAX_FD="$MAX_FD_LIMIT" 93 | fi 94 | ulimit -n $MAX_FD 95 | if [ $? -ne 0 ] ; then 96 | warn "Could not set maximum file descriptor limit: $MAX_FD" 97 | fi 98 | else 99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 100 | fi 101 | fi 102 | 103 | # For Darwin, add options to specify how the application appears in the dock 104 | if $darwin; then 105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 106 | fi 107 | 108 | # For Cygwin, switch paths to Windows format before running java 109 | if $cygwin ; then 110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 112 | JAVACMD=`cygpath --unix "$JAVACMD"` 113 | 114 | # We build the pattern for arguments to be converted via cygpath 115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 116 | SEP="" 117 | for dir in $ROOTDIRSRAW ; do 118 | ROOTDIRS="$ROOTDIRS$SEP$dir" 119 | SEP="|" 120 | done 121 | OURCYGPATTERN="(^($ROOTDIRS))" 122 | # Add a user-defined pattern to the cygpath arguments 123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 125 | fi 126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 127 | i=0 128 | for arg in "$@" ; do 129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 131 | 132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 134 | else 135 | eval `echo args$i`="\"$arg\"" 136 | fi 137 | i=$((i+1)) 138 | done 139 | case $i in 140 | (0) set -- ;; 141 | (1) set -- "$args0" ;; 142 | (2) set -- "$args0" "$args1" ;; 143 | (3) set -- "$args0" "$args1" "$args2" ;; 144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 150 | esac 151 | fi 152 | 153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 154 | function splitJvmOpts() { 155 | JVM_OPTS=("$@") 156 | } 157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 159 | 160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 161 | -------------------------------------------------------------------------------- /example/android/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # Attempt to set APP_HOME 46 | # Resolve links: $0 may be a link 47 | PRG="$0" 48 | # Need this for relative symlinks. 49 | while [ -h "$PRG" ] ; do 50 | ls=`ls -ld "$PRG"` 51 | link=`expr "$ls" : '.*-> \(.*\)$'` 52 | if expr "$link" : '/.*' > /dev/null; then 53 | PRG="$link" 54 | else 55 | PRG=`dirname "$PRG"`"/$link" 56 | fi 57 | done 58 | SAVED="`pwd`" 59 | cd "`dirname \"$PRG\"`/" >/dev/null 60 | APP_HOME="`pwd -P`" 61 | cd "$SAVED" >/dev/null 62 | 63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 64 | 65 | # Determine the Java command to use to start the JVM. 66 | if [ -n "$JAVA_HOME" ] ; then 67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 68 | # IBM's JDK on AIX uses strange locations for the executables 69 | JAVACMD="$JAVA_HOME/jre/sh/java" 70 | else 71 | JAVACMD="$JAVA_HOME/bin/java" 72 | fi 73 | if [ ! -x "$JAVACMD" ] ; then 74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 75 | 76 | Please set the JAVA_HOME variable in your environment to match the 77 | location of your Java installation." 78 | fi 79 | else 80 | JAVACMD="java" 81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 82 | 83 | Please set the JAVA_HOME variable in your environment to match the 84 | location of your Java installation." 85 | fi 86 | 87 | # Increase the maximum file descriptors if we can. 88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 89 | MAX_FD_LIMIT=`ulimit -H -n` 90 | if [ $? -eq 0 ] ; then 91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 92 | MAX_FD="$MAX_FD_LIMIT" 93 | fi 94 | ulimit -n $MAX_FD 95 | if [ $? -ne 0 ] ; then 96 | warn "Could not set maximum file descriptor limit: $MAX_FD" 97 | fi 98 | else 99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 100 | fi 101 | fi 102 | 103 | # For Darwin, add options to specify how the application appears in the dock 104 | if $darwin; then 105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 106 | fi 107 | 108 | # For Cygwin, switch paths to Windows format before running java 109 | if $cygwin ; then 110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 112 | JAVACMD=`cygpath --unix "$JAVACMD"` 113 | 114 | # We build the pattern for arguments to be converted via cygpath 115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 116 | SEP="" 117 | for dir in $ROOTDIRSRAW ; do 118 | ROOTDIRS="$ROOTDIRS$SEP$dir" 119 | SEP="|" 120 | done 121 | OURCYGPATTERN="(^($ROOTDIRS))" 122 | # Add a user-defined pattern to the cygpath arguments 123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 125 | fi 126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 127 | i=0 128 | for arg in "$@" ; do 129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 131 | 132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 134 | else 135 | eval `echo args$i`="\"$arg\"" 136 | fi 137 | i=$((i+1)) 138 | done 139 | case $i in 140 | (0) set -- ;; 141 | (1) set -- "$args0" ;; 142 | (2) set -- "$args0" "$args1" ;; 143 | (3) set -- "$args0" "$args1" "$args2" ;; 144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 150 | esac 151 | fi 152 | 153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 154 | function splitJvmOpts() { 155 | JVM_OPTS=("$@") 156 | } 157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 159 | 160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 161 | -------------------------------------------------------------------------------- /lib/src/app_upgrade.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter/widgets.dart'; 3 | import 'package:flutter_app_upgrade/flutter_app_upgrade.dart'; 4 | 5 | import 'download_status.dart'; 6 | import 'simple_app_upgrade.dart'; 7 | 8 | /// 9 | /// des:App 升级组件 10 | /// 11 | class AppUpgrade { 12 | /// 13 | /// App 升级组件入口函数,在`initState`方法中调用此函数即可。不要在[MaterialApp]控件的`initState`方法中调用, 14 | /// 需要在[Scaffold]的`body`控件内调用。 15 | /// 16 | /// `context`: 用于`showDialog`时使用。 17 | /// 18 | /// `future`:返回Future,通常情况下访问后台接口获取更新信息 19 | /// 20 | /// `titleStyle`:title 文字的样式 21 | /// 22 | /// `contentStyle`:版本信息内容文字样式 23 | /// 24 | /// `cancelText`:取消按钮文字,默认"取消" 25 | /// 26 | /// `cancelTextStyle`:取消按钮文字样式 27 | /// 28 | /// `okText`:升级按钮文字,默认"立即体验" 29 | /// 30 | /// `okTextStyle`:升级按钮文字样式 31 | /// 32 | /// `okBackgroundColors`:升级按钮背景颜色,需要2种颜色,左到右线性渐变,默认是系统的[primaryColor,primaryColor] 33 | /// 34 | /// `progressBarColor`:下载进度条颜色 35 | /// 36 | /// `borderRadius`:圆角半径,默认20 37 | /// 38 | /// `iosAppId`:ios app id,用于跳转app store,格式:idxxxxxxxx 39 | /// 40 | /// `appMarketInfo`:指定Android平台跳转到第三方应用市场更新,如果不指定将会弹出提示框,让用户选择哪一个应用市场。 41 | /// 42 | /// `onCancel`:点击取消按钮回调 43 | /// 44 | /// `onOk`:点击更新按钮回调 45 | /// 46 | /// `downloadProgress`:下载进度回调 47 | /// 48 | /// `downloadStatusChange`:下载状态变化回调 49 | /// 50 | static appUpgrade( 51 | BuildContext context, 52 | Future future, { 53 | TextStyle titleStyle, 54 | TextStyle contentStyle, 55 | String cancelText, 56 | TextStyle cancelTextStyle, 57 | String okText, 58 | TextStyle okTextStyle, 59 | List okBackgroundColors, 60 | Color progressBarColor, 61 | double borderRadius = 20.0, 62 | String iosAppId, 63 | AppMarketInfo appMarketInfo, 64 | VoidCallback onCancel, 65 | VoidCallback onOk, 66 | DownloadProgressCallback downloadProgress, 67 | DownloadStatusChangeCallback downloadStatusChange, 68 | }) { 69 | future.then((AppUpgradeInfo appUpgradeInfo) { 70 | if (appUpgradeInfo != null && appUpgradeInfo.title != null) { 71 | _showUpgradeDialog( 72 | context, appUpgradeInfo.title, appUpgradeInfo.contents, 73 | apkDownloadUrl: appUpgradeInfo.apkDownloadUrl, 74 | force: appUpgradeInfo.force, 75 | titleStyle: titleStyle, 76 | contentStyle: contentStyle, 77 | cancelText: cancelText, 78 | cancelTextStyle: cancelTextStyle, 79 | okBackgroundColors: okBackgroundColors, 80 | okText: okText, 81 | okTextStyle: okTextStyle, 82 | borderRadius: borderRadius, 83 | progressBarColor: progressBarColor, 84 | iosAppId: iosAppId, 85 | appMarketInfo: appMarketInfo, 86 | onCancel: onCancel, 87 | onOk: onOk, 88 | downloadProgress: downloadProgress, 89 | downloadStatusChange: downloadStatusChange); 90 | } 91 | }).catchError((onError) { 92 | print('$onError'); 93 | }); 94 | } 95 | 96 | /// 97 | /// 展示app升级提示框 98 | /// 99 | static _showUpgradeDialog( 100 | BuildContext context, 101 | String title, 102 | List contents, { 103 | String apkDownloadUrl, 104 | bool force = false, 105 | TextStyle titleStyle, 106 | TextStyle contentStyle, 107 | String cancelText, 108 | TextStyle cancelTextStyle, 109 | String okText, 110 | TextStyle okTextStyle, 111 | List okBackgroundColors, 112 | Color progressBarColor, 113 | double borderRadius = 20.0, 114 | String iosAppId, 115 | AppMarketInfo appMarketInfo, 116 | VoidCallback onCancel, 117 | VoidCallback onOk, 118 | DownloadProgressCallback downloadProgress, 119 | DownloadStatusChangeCallback downloadStatusChange, 120 | }) { 121 | showDialog( 122 | context: context, 123 | barrierDismissible: false, 124 | builder: (context) { 125 | return WillPopScope( 126 | onWillPop: () async { 127 | return false; 128 | }, 129 | child: Dialog( 130 | shape: RoundedRectangleBorder( 131 | borderRadius: 132 | BorderRadius.all(Radius.circular(borderRadius))), 133 | child: SimpleAppUpgradeWidget( 134 | title: title, 135 | titleStyle: titleStyle, 136 | contents: contents, 137 | contentStyle: contentStyle, 138 | cancelText: cancelText, 139 | cancelTextStyle: cancelTextStyle, 140 | okText: okText, 141 | okTextStyle: okTextStyle, 142 | okBackgroundColors: okBackgroundColors ?? 143 | [ 144 | Theme.of(context).primaryColor, 145 | Theme.of(context).primaryColor 146 | ], 147 | progressBarColor: progressBarColor, 148 | borderRadius: borderRadius, 149 | downloadUrl: apkDownloadUrl, 150 | force: force, 151 | iosAppId: iosAppId, 152 | appMarketInfo: appMarketInfo, 153 | onCancel: onCancel, 154 | onOk: onOk, 155 | downloadProgress: downloadProgress, 156 | downloadStatusChange: downloadStatusChange 157 | )), 158 | ); 159 | }); 160 | } 161 | } 162 | 163 | class AppInfo { 164 | AppInfo({this.versionName, this.versionCode, this.packageName}); 165 | 166 | String versionName; 167 | String versionCode; 168 | String packageName; 169 | } 170 | 171 | class AppUpgradeInfo { 172 | AppUpgradeInfo( 173 | {@required this.title, 174 | @required this.contents, 175 | this.apkDownloadUrl, 176 | this.force = false}); 177 | 178 | /// 179 | /// title,显示在提示框顶部 180 | /// 181 | final String title; 182 | 183 | /// 184 | /// 升级内容 185 | /// 186 | final List contents; 187 | 188 | /// 189 | /// apk下载url 190 | /// 191 | final String apkDownloadUrl; 192 | 193 | /// 194 | /// 是否强制升级 195 | /// 196 | final bool force; 197 | } 198 | 199 | /// 200 | /// 下载进度回调 201 | /// 202 | typedef DownloadProgressCallback = Function(int count, int total); 203 | 204 | /// 205 | /// 下载状态变化回调 206 | /// 207 | typedef DownloadStatusChangeCallback = Function(DownloadStatus downloadStatus, 208 | {dynamic error}); 209 | -------------------------------------------------------------------------------- /android/src/main/kotlin/com/flutter/flutter_app_upgrade/FlutterAppUpgradePlugin.kt: -------------------------------------------------------------------------------- 1 | package com.flutter.flutter_app_upgrade 2 | 3 | import android.content.ActivityNotFoundException 4 | import android.content.Context 5 | import android.content.Intent 6 | import android.content.pm.PackageManager 7 | import android.net.Uri 8 | import android.os.Build 9 | import android.widget.Toast 10 | import androidx.annotation.NonNull 11 | import androidx.core.content.FileProvider 12 | import io.flutter.embedding.engine.plugins.FlutterPlugin 13 | import io.flutter.embedding.engine.plugins.activity.ActivityAware 14 | import io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding 15 | import io.flutter.plugin.common.MethodCall 16 | import io.flutter.plugin.common.MethodChannel 17 | import io.flutter.plugin.common.MethodChannel.MethodCallHandler 18 | import io.flutter.plugin.common.MethodChannel.Result 19 | import io.flutter.plugin.common.PluginRegistry.Registrar 20 | import java.io.File 21 | import java.util.* 22 | 23 | /** FlutterUpgradePlugin */ 24 | public class FlutterAppUpgradePlugin : FlutterPlugin, MethodCallHandler, ActivityAware { 25 | 26 | 27 | override fun onDetachedFromActivity() { 28 | } 29 | 30 | override fun onReattachedToActivityForConfigChanges(binding: ActivityPluginBinding) { 31 | } 32 | 33 | override fun onAttachedToActivity(binding: ActivityPluginBinding) { 34 | mContext = binding.activity 35 | } 36 | 37 | override fun onDetachedFromActivityForConfigChanges() { 38 | } 39 | 40 | 41 | override fun onAttachedToEngine(@NonNull flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) { 42 | val channel = MethodChannel(flutterPluginBinding.getFlutterEngine().getDartExecutor(), "flutter_app_upgrade") 43 | channel.setMethodCallHandler(FlutterAppUpgradePlugin()) 44 | } 45 | 46 | companion object { 47 | lateinit var mContext: Context 48 | 49 | @JvmStatic 50 | fun registerWith(registrar: Registrar) { 51 | this.mContext = registrar.activity() 52 | val channel = MethodChannel(registrar.messenger(), "flutter_app_upgrade") 53 | channel.setMethodCallHandler(FlutterAppUpgradePlugin()) 54 | } 55 | 56 | } 57 | 58 | override fun onMethodCall(@NonNull call: MethodCall, @NonNull result: Result) { 59 | if (call.method == "getAppInfo") { 60 | getAppInfo(mContext, result) 61 | } else if (call.method == "getApkDownloadPath") { 62 | result.success(mContext.getExternalFilesDir("").absolutePath) 63 | } else if (call.method == "install") { 64 | //安装app 65 | val path = call.argument("path") 66 | path?.also { 67 | startInstall(mContext, it) 68 | } 69 | } else if (call.method == "getInstallMarket") { 70 | var packageList = getInstallMarket(call.argument>("packages")) 71 | result.success(packageList) 72 | } else if (call.method == "toMarket") { 73 | val marketPackageName = call.argument("marketPackageName") 74 | val marketClassName = call.argument("marketClassName") 75 | toMarket(mContext, marketPackageName, marketClassName) 76 | } else { 77 | result.notImplemented() 78 | } 79 | } 80 | 81 | /** 82 | * 获取app信息 83 | */ 84 | fun getAppInfo(context: Context?, result: Result) { 85 | context?.also { 86 | var packageInfo = it.packageManager.getPackageInfo(it.packageName, 0) 87 | val map = HashMap() 88 | map["packageName"] = packageInfo.packageName 89 | map["versionName"] = packageInfo.versionName 90 | map["versionCode"] = "${packageInfo.versionCode}" 91 | result.success(map) 92 | } 93 | } 94 | 95 | /** 96 | * 如果手机上安装多个应用市场则弹出对话框,由用户选择进入哪个市场 97 | */ 98 | fun toMarket(context: Context) { 99 | try { 100 | var packageInfo = context.packageManager.getPackageInfo(context.packageName, 0) 101 | val uri = Uri.parse("market://details?id=${packageInfo.packageName}") 102 | val goToMarket = Intent(Intent.ACTION_VIEW, uri) 103 | goToMarket.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) 104 | context.startActivity(goToMarket) 105 | } catch (e: ActivityNotFoundException) { 106 | e.printStackTrace() 107 | Toast.makeText(context, "您的手机没有安装应用商店", Toast.LENGTH_SHORT).show() 108 | } 109 | } 110 | 111 | /** 112 | * 直接跳转到指定应用市场 113 | * 114 | * @param context 115 | * @param packageName 116 | */ 117 | fun toMarket(context: Context, marketPackageName: String?, marketClassName: String?) { 118 | try { 119 | var packageInfo = context.packageManager.getPackageInfo(context.packageName, 0) 120 | val uri = Uri.parse("market://details?id=${packageInfo.packageName}") 121 | var nameEmpty = marketPackageName == null || marketPackageName.isEmpty() 122 | var classEmpty = marketClassName == null || marketClassName.isEmpty() 123 | val goToMarket = Intent(Intent.ACTION_VIEW, uri) 124 | if (nameEmpty || classEmpty) { 125 | goToMarket.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) 126 | } else { 127 | goToMarket.setClassName(marketPackageName, marketClassName) 128 | } 129 | context.startActivity(goToMarket) 130 | } catch (e: ActivityNotFoundException) { 131 | e.printStackTrace() 132 | Toast.makeText(context, "您的手机没有安装应用商店($marketPackageName)", Toast.LENGTH_SHORT).show() 133 | } 134 | } 135 | 136 | /** 137 | * 获取已安装应用商店的包名列表 138 | */ 139 | fun getInstallMarket(packages: List?): List { 140 | val pkgs = ArrayList() 141 | packages?.also { 142 | for (i in packages.indices) { 143 | if (isPackageExist(mContext, packages.get(i))) { 144 | pkgs.add(packages.get(i)) 145 | } 146 | } 147 | } 148 | return pkgs 149 | } 150 | 151 | /** 152 | * 是否存在当前应用市场 153 | * 154 | */ 155 | fun isPackageExist(context: Context, packageName: String?): Boolean { 156 | val manager = context.packageManager 157 | val intent = Intent().setPackage(packageName) 158 | val infos = manager.queryIntentActivities(intent, 159 | PackageManager.GET_INTENT_FILTERS) 160 | return if (infos == null || infos.size < 1) { 161 | false 162 | } else { 163 | true 164 | } 165 | } 166 | 167 | /** 168 | * 安装app,android 7.0及以上和以下方式不同 169 | */ 170 | private fun startInstall(context: Context, path: String) { 171 | val file = File(path) 172 | if (!file.exists()) { 173 | return 174 | } 175 | 176 | val intent = Intent(Intent.ACTION_VIEW) 177 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { 178 | //7.0及以上 179 | 180 | val contentUri = FileProvider.getUriForFile(context, "${context.packageName}.fileprovider", file) 181 | intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK 182 | intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION) 183 | intent.setDataAndType(contentUri, "application/vnd.android.package-archive") 184 | context.startActivity(intent) 185 | } else { 186 | //7.0以下 187 | intent.setDataAndType(Uri.fromFile(file), "application/vnd.android.package-archive") 188 | intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) 189 | context.startActivity(intent) 190 | } 191 | 192 | } 193 | 194 | override fun onDetachedFromEngine(@NonNull binding: FlutterPlugin.FlutterPluginBinding) { 195 | } 196 | } 197 | 198 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | > 官网地址:[http://laomengit.com/plugin/upgrade.html](http://laomengit.com/plugin/upgrade.html) 3 | 4 | # 添加依赖 5 | 6 | 1、在`pubspec.yaml`中加入: 7 | 8 | ``` 9 | dependencies: 10 | flutter_app_upgrade: ^1.1.0 11 | ``` 12 | 13 | 2、执行flutter命令获取包: 14 | ``` 15 | flutter pub get` 16 | ``` 17 | 18 | 3、引入 19 | 20 | ``` 21 | import 'package:flutter_app_upgrade/flutter_app_upgrade.dart'; 22 | 23 | ``` 24 | 25 | 4、如果你需要支持Android平台,在`./android/app/src/main/AndroidManifest.xml`文件中配置`provider`,代码如下: 26 | 27 | ``` 28 | 31 | 35 | ... 36 | 41 | 45 | 46 | 47 | 48 | ``` 49 | 50 | > 注意:provider中authorities的值为当前App的包名,和顶部的package值保持一致。 51 | 52 | 53 | 54 | ## App升级功能使用介绍 55 | 56 | 57 | 58 | 只需在主页的`initState`方法中调用升级检测方法: 59 | 60 | ```dart 61 | @override 62 | void initState() { 63 | AppUpgrade.appUpgrade( 64 | context, 65 | _checkAppInfo(), 66 | iosAppId: 'id88888888', 67 | ); 68 | super.initState(); 69 | } 70 | ``` 71 | 72 | `_checkAppInfo`方法访问后台接口获取是否有新的版本的信息,返回`Future` 类型,`AppUpgradeInfo`包含title、升级内容、apk下载url、是否强制升级等版本信息。如果没有新的版本不返回即可。 73 | 74 | `iosAppId`参数用于跳转到app store。 75 | 76 | `_checkAppInfo()`方法通常是访问后台接口,这里直接返回新版本信息,代码如下: 77 | 78 | ```dart 79 | Future _checkAppInfo() async { 80 | //这里一般访问网络接口,将返回的数据解析成如下格式 81 | return Future.delayed(Duration(seconds: 1), () { 82 | return AppUpgradeInfo( 83 | title: '新版本V1.1.1', 84 | contents: [ 85 | '1、支持立体声蓝牙耳机,同时改善配对性能', 86 | '2、提供屏幕虚拟键盘', 87 | '3、更简洁更流畅,使用起来更快', 88 | '4、修复一些软件在使用时自动退出bug', 89 | '5、新增加了分类查看功能' 90 | ], 91 | force: false, 92 | ); 93 | }); 94 | } 95 | ``` 96 | 97 | 好了,基本的升级功能就完成了,弹出提示框的效果如下: 98 | 99 | ![](https://github.com/781238222/imgs/raw/master/flutter_upgrade/app_upgrade_3.png) 100 | 101 | 点击“以后再说”,提示框消失,点击“立即体验”,自动区分不同平台。 102 | 103 | 访问后台接口获取新版本的信息一般需要当前App的包名和版本,查询方法如下: 104 | 105 | ```dart 106 | await FlutterUpgrade.appInfo 107 | ``` 108 | 109 | 返回的类型是`AppInfo`: 110 | 111 | - versionName:版本号,比如1.0.0。 112 | - versionCode:Android独有版本号,对应Android build.gradle中的versionCode,ios返回“0”。 113 | - packageName:包名,对应Android build.gradle中的applicationId,ios的BundleIdentifier。 114 | 115 | ### iOS平台升级 116 | 117 | iOS平台直接跳转到app store相关页面,`iosAppId`一定要设置对,否则app store会找不到应用程序。 118 | 119 | ### Android平台下载apk 120 | 121 | Android平台则会判断是否设置了apk下载url,如果设置了则下载apk则直接下载,效果如下: 122 | 123 | ![](https://github.com/781238222/imgs/raw/master/flutter_upgrade/app_upgrade_4.gif) 124 | 125 | 当下载完成时直接跳转到apk安装引导界面,效果如下: 126 | 127 | ![](https://github.com/781238222/imgs/raw/master/flutter_upgrade/app_upgrade_5.png) 128 | 129 | 用户点击允许,出现如下界面: 130 | 131 | ![](https://github.com/781238222/imgs/raw/master/flutter_upgrade/app_upgrade_6.png) 132 | 133 | 点击继续安装即可,上面的安装引导界面是系统界面,不同的手机或者不同的Android版本会略有不同。 134 | 135 | 136 | 137 | ### Android平台跳转应用市场 138 | 139 | 如果不提供apk下载地址,点击“立即体验”,则会跳转到应用市场,不指定应用市场则会弹出提示框,让用户选择应用市场,效果如下: 140 | 141 | ![](https://github.com/781238222/imgs/raw/master/flutter_upgrade/app_upgrade_7.png) 142 | 143 | 提示框内将会包含手机内安装的所有的应用市场,用户选择一个然后跳转到对应应用市场的详情界面,如果当前应用未在此市场上架则会出现“找不到的界面”。 144 | 145 | 通常情况下会指定应用市场,这就需要知道用户手机内安装的应用市场,查询方法如下: 146 | 147 | ```dart 148 | _getInstallMarket() async { 149 | List marketList = await FlutterUpgrade.getInstallMarket(); 150 | } 151 | ``` 152 | 153 | 插件内置了国内常用的应用市场,包括小米、魅族、vivo、oppo、华为、zte、360助手、应用宝、pp助手、豌豆荚,如果你需要检测其他的应用市场,比如google play,只需添加googl play的包名即可: 154 | 155 | ```dart 156 | _getInstallMarket() async { 157 | List marketList = await FlutterUpgrade.getInstallMarket(marketPackageNames: ['google play 包名']); 158 | } 159 | ``` 160 | 161 | 方法返回手机安装的应用市场,根据安装的应用市场指定跳转应用市场,如果你要指定内置的应用市场,可以根据包名获取内置的应用市场的相关信息: 162 | 163 | ```dart 164 | AppMarketInfo _marketInfo = AppMarket.getBuildInMarket(packageName); 165 | ``` 166 | 167 | 指定华为应用市场: 168 | 169 | ```dart 170 | AppUpgrade.appUpgrade( 171 | context, 172 | _checkAppInfo(), 173 | iosAppId: 'id88888888', 174 | appMarketInfo: AppMarket.huaWei 175 | ); 176 | ``` 177 | 178 | 指定没有内置的应用市场方法如下: 179 | 180 | ```dart 181 | AppUpgrade.appUpgrade( 182 | context, 183 | _checkAppInfo(), 184 | iosAppId: 'id88888888', 185 | appMarketInfo: AppMarketInfo( 186 | '应用市场名称(选填)','应用市场包名','应用市场类名' 187 | ), 188 | ); 189 | ``` 190 | 191 | 192 | 193 | ### 用户行为和下载回调 194 | 195 | 新的版本(1.1.0)新增了**取消** 和**立即更新**回调,用法如下: 196 | 197 | ```dart 198 | AppUpgrade.appUpgrade( 199 | context, 200 | _checkAppInfo(), 201 | cancelText: '以后再说', 202 | okText: '马上升级', 203 | iosAppId: 'id88888888', 204 | appMarketInfo: AppMarket.huaWei, 205 | onCancel: () { 206 | print('onCancel'); 207 | }, 208 | onOk: () { 209 | print('onOk'); 210 | }, 211 | 212 | ); 213 | ``` 214 | 215 | 新增的**下载进度**和**下载状态变化**回调,用法如下: 216 | 217 | ```dart 218 | AppUpgrade.appUpgrade( 219 | context, 220 | _checkAppInfo(), 221 | cancelText: '以后再说', 222 | okText: '马上升级', 223 | iosAppId: 'id88888888', 224 | appMarketInfo: AppMarket.huaWei, 225 | downloadProgress: (count, total) { 226 | print('count:$count,total:$total'); 227 | }, 228 | downloadStatusChange: (DownloadStatus status, {dynamic error}) { 229 | print('status:$status,error:$error'); 230 | }, 231 | ); 232 | ``` 233 | 234 | 235 | 236 | ## 提示框样式定制 237 | 238 | 如果默认的升级提示框不满足你的需求,那么你可以定制你的升级提示框。 239 | 240 | title及升级内容文字样式设置: 241 | 242 | ```dart 243 | AppUpgrade.appUpgrade(context, _checkAppInfo(), 244 | titleStyle: TextStyle(fontSize: 30), 245 | contentStyle: TextStyle(fontSize: 18), 246 | ... 247 | ) 248 | ``` 249 | 250 | 通过`titleStyle`和`contentStyle`设置其样式,可以设置字体大小、颜色、粗体等。 251 | 252 | 设置“取消”和“升级按钮”文本和样式: 253 | 254 | ```dart 255 | AppUpgrade.appUpgrade(context, _checkAppInfo(), 256 | cancelText: '以后再说', 257 | cancelTextStyle: TextStyle(color: Colors.grey), 258 | okText: '马上升级', 259 | okTextStyle: TextStyle(color: Colors.red), 260 | ... 261 | ) 262 | ``` 263 | 264 | 默认“取消”按钮文本是"以后再说",默认“升级”按钮的文本是“立即体验”。 265 | 266 | 设置“升级”按钮的背景颜色,需要2种颜色,2种颜色左到右线性渐变,如果想设置纯色,只需将2种颜色设置为同一个颜色即可,默认颜色是系统的`primaryColor`: 267 | 268 | ```dart 269 | AppUpgrade.appUpgrade(context, _checkAppInfo(), 270 | okBackgroundColors: [Colors.blue, Colors.lightBlue], 271 | ... 272 | ) 273 | ``` 274 | 275 | 设置进度条的颜色: 276 | 277 | ```dart 278 | AppUpgrade.appUpgrade(context, _checkAppInfo(), 279 | progressBarColor: Colors.lightBlue.withOpacity(.4), 280 | ... 281 | ) 282 | ``` 283 | 284 | 设置升级提示框的圆角半径,默认是20: 285 | 286 | ```dart 287 | AppUpgrade.appUpgrade(context, _checkAppInfo(), 288 | borderRadius: 15, 289 | ... 290 | ) 291 | ``` 292 | 293 | 294 | 295 | 296 | 297 | ## Flutter App 升级功能流程 298 | 299 | 应用程序升级功能是App的基础功能之一,如果没有此功能会造成用户无法升级,应用程序的bug或者新功能老用户无法触达,甚至损失这部分用户。 300 | 301 | 302 | 对于应用程序升级功能的重要性就无需赘言了,下面介绍下应用程序升级功能的几种方式,从平台方面来说: 303 | 304 | - IOS平台,应用程序升级功能只能通过跳转到app store进行升级。 305 | - Android平台,既可以通过跳转到应用市场进行升级,也可以下载apk包升级。 306 | 307 | 从强制性来说可以分别强制升级和非强制升级: 308 | 309 | - 强制升级:就是用户必须升级才能继续使用App,如果不是非常必要不建议使用如此强硬的方式,会造成用户的反感。 310 | - 非强制升级就是允许用户点击“取消”,继续使用App。 311 | 312 | 313 | 314 | 下面分别介绍IOS和Android升级流程。 315 | 316 | ## IOS升级流程 317 | 318 | IOS升级流程如下: 319 | 320 | ![](https://github.com/781238222/imgs/raw/master/flutter_upgrade/app_upgrade_1.png) 321 | 322 | 流程说明: 323 | 324 | 1. 通常我们会访问后台接口获取是否有新的版本,如果有新的版本则弹出提示框,判断当前版本是否为“强制升级”,如果是则只提供用户一个“升级”的按钮,否则提供用户“升级”和“取消”按钮。 325 | 2. 弹出提示框后用户选择是否升级,如果选择“取消”,提示框消失,如果选择“升级”,跳转到app store进行升级。 326 | 327 | 328 | 329 | ## Android 升级流程 330 | 331 | 相比ios的升级过程,Android就稍显复杂了,流程图如下: 332 | 333 | ![](https://github.com/781238222/imgs/raw/master/flutter_upgrade/app_upgrade_2.png) 334 | 335 | 流程说明: 336 | 337 | 1. 访问后台接口获取是否有新的版本,这里和IOS是一样的,有则弹出升级提示框,判断当前版本是否为“强制升级”,如果是则只提供用户一个“升级”的按钮,否则提供用户“升级”和“取消”按钮。 338 | 2. 弹出提示框后有用户选择是否升级,如果选择“取消”,提示框消失,如果选择“升级”,判断是跳转到应用市场进行升级还是通过下载apk升级。 339 | 3. 如果下载apk升级,则开始下载apk,下载完成后跳转到apk安装引导界面。 340 | 4. 如果跳转到应用市场升级,判断是否指定了应用市场,比如只在华为应用市场上架了,那么此时需要指定跳转到华为应用市场,即使你在很多应用市场都上架了,也应该根据用户手机安装的应用市场指定一个应用市场,让用户选择应用市场不是一个好的体验,而且用户也不知道应该去哪个市场更新,如果用户选择了一个你没有上架的应用市场,那就更尴尬了。 341 | 5. 指定应用市场后直接跳转到指定的应用市场的更新界面。 342 | 343 | -------------------------------------------------------------------------------- /lib/src/simple_app_upgrade.dart: -------------------------------------------------------------------------------- 1 | import 'dart:io'; 2 | 3 | import 'package:dio/dio.dart'; 4 | import 'package:flutter/material.dart'; 5 | import 'package:flutter_app_upgrade/flutter_app_upgrade.dart'; 6 | import 'package:flutter_app_upgrade/src/download_status.dart'; 7 | 8 | import 'liquid_progress_indicator.dart'; 9 | 10 | /// 11 | /// des:app升级提示控件 12 | /// 13 | class SimpleAppUpgradeWidget extends StatefulWidget { 14 | const SimpleAppUpgradeWidget( 15 | {@required this.title, 16 | this.titleStyle, 17 | @required this.contents, 18 | this.contentStyle, 19 | this.cancelText, 20 | this.cancelTextStyle, 21 | this.okText, 22 | this.okTextStyle, 23 | this.okBackgroundColors, 24 | this.progressBar, 25 | this.progressBarColor, 26 | this.borderRadius = 10, 27 | this.downloadUrl, 28 | this.force = false, 29 | this.iosAppId, 30 | this.appMarketInfo, 31 | this.onCancel, 32 | this.onOk, 33 | this.downloadProgress, 34 | this.downloadStatusChange}); 35 | 36 | /// 37 | /// 升级标题 38 | /// 39 | final String title; 40 | 41 | /// 42 | /// 标题样式 43 | /// 44 | final TextStyle titleStyle; 45 | 46 | /// 47 | /// 升级提示内容 48 | /// 49 | final List contents; 50 | 51 | /// 52 | /// 提示内容样式 53 | /// 54 | final TextStyle contentStyle; 55 | 56 | /// 57 | /// 下载进度条 58 | /// 59 | final Widget progressBar; 60 | 61 | /// 62 | /// 进度条颜色 63 | /// 64 | final Color progressBarColor; 65 | 66 | /// 67 | /// 确认控件 68 | /// 69 | final String okText; 70 | 71 | /// 72 | /// 确认控件样式 73 | /// 74 | final TextStyle okTextStyle; 75 | 76 | /// 77 | /// 确认控件背景颜色,2种颜色左到右线性渐变 78 | /// 79 | final List okBackgroundColors; 80 | 81 | /// 82 | /// 取消控件 83 | /// 84 | final String cancelText; 85 | 86 | /// 87 | /// 取消控件样式 88 | /// 89 | final TextStyle cancelTextStyle; 90 | 91 | /// 92 | /// app安装包下载url,没有下载跳转到应用宝等渠道更新 93 | /// 94 | final String downloadUrl; 95 | 96 | /// 97 | /// 圆角半径 98 | /// 99 | final double borderRadius; 100 | 101 | /// 102 | /// 是否强制升级,设置true没有取消按钮 103 | /// 104 | final bool force; 105 | 106 | /// 107 | /// ios app id,用于跳转app store 108 | /// 109 | final String iosAppId; 110 | 111 | /// 112 | /// 指定跳转的应用市场, 113 | /// 如果不指定将会弹出提示框,让用户选择哪一个应用市场。 114 | /// 115 | final AppMarketInfo appMarketInfo; 116 | 117 | final VoidCallback onCancel; 118 | final VoidCallback onOk; 119 | final DownloadProgressCallback downloadProgress; 120 | final DownloadStatusChangeCallback downloadStatusChange; 121 | 122 | @override 123 | State createState() => _SimpleAppUpgradeWidget(); 124 | } 125 | 126 | class _SimpleAppUpgradeWidget extends State { 127 | static final String _downloadApkName = 'temp.apk'; 128 | 129 | /// 130 | /// 下载进度 131 | /// 132 | double _downloadProgress = 0.0; 133 | 134 | DownloadStatus _downloadStatus = DownloadStatus.none; 135 | 136 | @override 137 | Widget build(BuildContext context) { 138 | return Container( 139 | child: Stack( 140 | children: [ 141 | _buildInfoWidget(context), 142 | _downloadProgress > 0 143 | ? Positioned.fill(child: _buildDownloadProgress()) 144 | : Container( 145 | height: 10, 146 | ) 147 | ], 148 | ), 149 | ); 150 | } 151 | 152 | /// 153 | /// 信息展示widget 154 | /// 155 | Widget _buildInfoWidget(BuildContext context) { 156 | return Container( 157 | child: Column( 158 | mainAxisSize: MainAxisSize.min, 159 | children: [ 160 | //标题 161 | _buildTitle(), 162 | //更新信息 163 | _buildAppInfo(), 164 | //操作按钮 165 | _buildAction() 166 | ], 167 | ), 168 | ); 169 | } 170 | 171 | /// 172 | /// 构建标题 173 | /// 174 | _buildTitle() { 175 | return Padding( 176 | padding: EdgeInsets.only(top: 20, bottom: 30), 177 | child: Text(widget.title ?? '', 178 | style: widget.titleStyle ?? TextStyle(fontSize: 22))); 179 | } 180 | 181 | /// 182 | /// 构建版本更新信息 183 | /// 184 | _buildAppInfo() { 185 | return Container( 186 | padding: EdgeInsets.only(left: 15, right: 15, bottom: 30), 187 | height: 200, 188 | child: ListView( 189 | children: widget.contents.map((f) { 190 | return Text( 191 | f, 192 | style: widget.contentStyle ?? TextStyle(), 193 | ); 194 | }).toList(), 195 | )); 196 | } 197 | 198 | /// 199 | /// 构建取消或者升级按钮 200 | /// 201 | _buildAction() { 202 | return Column( 203 | children: [ 204 | Divider( 205 | height: 1, 206 | color: Colors.grey, 207 | ), 208 | Row( 209 | children: [ 210 | widget.force 211 | ? Container() 212 | : Expanded( 213 | child: _buildCancelActionButton(), 214 | ), 215 | Expanded( 216 | child: _buildOkActionButton(), 217 | ), 218 | ], 219 | ), 220 | ], 221 | ); 222 | } 223 | 224 | /// 225 | /// 取消按钮 226 | /// 227 | _buildCancelActionButton() { 228 | return Ink( 229 | decoration: BoxDecoration( 230 | borderRadius: BorderRadius.only( 231 | bottomLeft: Radius.circular(widget.borderRadius))), 232 | child: InkWell( 233 | borderRadius: BorderRadius.only( 234 | bottomLeft: Radius.circular(widget.borderRadius)), 235 | child: Container( 236 | height: 45, 237 | alignment: Alignment.center, 238 | child: Text(widget.cancelText ?? '以后再说', 239 | style: widget.cancelTextStyle ?? TextStyle()), 240 | ), 241 | onTap: () { 242 | widget.onCancel?.call(); 243 | Navigator.of(context).pop(); 244 | }), 245 | ); 246 | } 247 | 248 | /// 249 | /// 确定按钮 250 | /// 251 | _buildOkActionButton() { 252 | var borderRadius = 253 | BorderRadius.only(bottomRight: Radius.circular(widget.borderRadius)); 254 | if (widget.force) { 255 | borderRadius = BorderRadius.only( 256 | bottomRight: Radius.circular(widget.borderRadius), 257 | bottomLeft: Radius.circular(widget.borderRadius)); 258 | } 259 | var _okBackgroundColors = widget.okBackgroundColors; 260 | if (widget.okBackgroundColors == null || 261 | widget.okBackgroundColors.length != 2) { 262 | _okBackgroundColors = [ 263 | Theme.of(context).primaryColor, 264 | Theme.of(context).primaryColor 265 | ]; 266 | } 267 | return Ink( 268 | decoration: BoxDecoration( 269 | gradient: LinearGradient( 270 | begin: Alignment.topLeft, 271 | end: Alignment.bottomRight, 272 | colors: [_okBackgroundColors[0], _okBackgroundColors[1]]), 273 | borderRadius: borderRadius), 274 | child: InkWell( 275 | borderRadius: borderRadius, 276 | child: Container( 277 | height: 45, 278 | alignment: Alignment.center, 279 | child: Text(widget.okText ?? '立即体验', 280 | style: widget.okTextStyle ?? TextStyle(color: Colors.white)), 281 | ), 282 | onTap: () { 283 | _clickOk(); 284 | }, 285 | ), 286 | ); 287 | } 288 | 289 | /// 290 | /// 下载进度widget 291 | /// 292 | Widget _buildDownloadProgress() { 293 | return widget.progressBar ?? 294 | LiquidLinearProgressIndicator( 295 | value: _downloadProgress, 296 | direction: Axis.vertical, 297 | valueColor: AlwaysStoppedAnimation(widget.progressBarColor ?? 298 | Theme.of(context).primaryColor.withOpacity(0.4)), 299 | borderRadius: widget.borderRadius, 300 | ); 301 | } 302 | 303 | /// 304 | /// 点击确定按钮 305 | /// 306 | _clickOk() async { 307 | widget.onOk?.call(); 308 | if (Platform.isIOS) { 309 | //ios 需要跳转到app store更新,原生实现 310 | FlutterUpgrade.toAppStore(widget.iosAppId); 311 | return; 312 | } 313 | if (widget.downloadUrl == null || widget.downloadUrl.isEmpty) { 314 | //没有下载地址,跳转到第三方渠道更新,原生实现 315 | FlutterUpgrade.toMarket(appMarketInfo: widget.appMarketInfo); 316 | return; 317 | } 318 | String path = await FlutterUpgrade.apkDownloadPath; 319 | _downloadApk(widget.downloadUrl, '$path/$_downloadApkName'); 320 | } 321 | 322 | /// 323 | /// 下载apk包 324 | /// 325 | _downloadApk(String url, String path) async { 326 | if (_downloadStatus == DownloadStatus.start || 327 | _downloadStatus == DownloadStatus.downloading || 328 | _downloadStatus == DownloadStatus.done) { 329 | print('当前下载状态:$_downloadStatus,不能重复下载。'); 330 | return; 331 | } 332 | 333 | _updateDownloadStatus(DownloadStatus.start); 334 | try { 335 | var dio = Dio(); 336 | await dio.download(url, path, onReceiveProgress: (int count, int total) { 337 | if (total == -1) { 338 | _downloadProgress = 0.01; 339 | } else { 340 | widget.downloadProgress?.call(count, total); 341 | _downloadProgress = count / total.toDouble(); 342 | } 343 | setState(() {}); 344 | if (_downloadProgress == 1) { 345 | //下载完成,跳转到程序安装界面 346 | _updateDownloadStatus(DownloadStatus.done); 347 | Navigator.pop(context); 348 | FlutterUpgrade.installAppForAndroid(path); 349 | } 350 | }); 351 | } catch (e) { 352 | print('$e'); 353 | _downloadProgress = 0; 354 | _updateDownloadStatus(DownloadStatus.error,error: e); 355 | } 356 | } 357 | 358 | _updateDownloadStatus(DownloadStatus downloadStatus, {dynamic error}) { 359 | _downloadStatus = downloadStatus; 360 | widget.downloadStatusChange?.call(_downloadStatus, error: error); 361 | } 362 | } 363 | -------------------------------------------------------------------------------- /example/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 | 357CEA3DD166D61981364651 /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9346FD54D8FA008F7B2889E1 /* 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 | 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; }; 34 | 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; }; 35 | 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; 36 | 5DC2C5BA3F6773854AB1A3F4 /* 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 = ""; }; 37 | 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = ""; }; 38 | 74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 39 | 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; }; 40 | 9346FD54D8FA008F7B2889E1 /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 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 | BA2A314F1827D933F08CFF98 /* 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 = ""; }; 49 | ECA0833E8C2ECD8B733276F1 /* 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 = ""; }; 50 | /* End PBXFileReference section */ 51 | 52 | /* Begin PBXFrameworksBuildPhase section */ 53 | 97C146EB1CF9000F007C117D /* Frameworks */ = { 54 | isa = PBXFrameworksBuildPhase; 55 | buildActionMask = 2147483647; 56 | files = ( 57 | 357CEA3DD166D61981364651 /* Pods_Runner.framework in Frameworks */, 58 | ); 59 | runOnlyForDeploymentPostprocessing = 0; 60 | }; 61 | /* End PBXFrameworksBuildPhase section */ 62 | 63 | /* Begin PBXGroup section */ 64 | 6306C8D9613F5AE4C6426757 /* Pods */ = { 65 | isa = PBXGroup; 66 | children = ( 67 | 5DC2C5BA3F6773854AB1A3F4 /* Pods-Runner.debug.xcconfig */, 68 | BA2A314F1827D933F08CFF98 /* Pods-Runner.release.xcconfig */, 69 | ECA0833E8C2ECD8B733276F1 /* Pods-Runner.profile.xcconfig */, 70 | ); 71 | name = Pods; 72 | path = Pods; 73 | sourceTree = ""; 74 | }; 75 | 9740EEB11CF90186004384FC /* Flutter */ = { 76 | isa = PBXGroup; 77 | children = ( 78 | 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */, 79 | 9740EEB21CF90195004384FC /* Debug.xcconfig */, 80 | 7AFA3C8E1D35360C0083082E /* Release.xcconfig */, 81 | 9740EEB31CF90195004384FC /* Generated.xcconfig */, 82 | ); 83 | name = Flutter; 84 | sourceTree = ""; 85 | }; 86 | 97C146E51CF9000F007C117D = { 87 | isa = PBXGroup; 88 | children = ( 89 | 9740EEB11CF90186004384FC /* Flutter */, 90 | 97C146F01CF9000F007C117D /* Runner */, 91 | 97C146EF1CF9000F007C117D /* Products */, 92 | 6306C8D9613F5AE4C6426757 /* Pods */, 93 | B348084BAE979BBCB2F7D868 /* Frameworks */, 94 | ); 95 | sourceTree = ""; 96 | }; 97 | 97C146EF1CF9000F007C117D /* Products */ = { 98 | isa = PBXGroup; 99 | children = ( 100 | 97C146EE1CF9000F007C117D /* Runner.app */, 101 | ); 102 | name = Products; 103 | sourceTree = ""; 104 | }; 105 | 97C146F01CF9000F007C117D /* Runner */ = { 106 | isa = PBXGroup; 107 | children = ( 108 | 97C146FA1CF9000F007C117D /* Main.storyboard */, 109 | 97C146FD1CF9000F007C117D /* Assets.xcassets */, 110 | 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */, 111 | 97C147021CF9000F007C117D /* Info.plist */, 112 | 97C146F11CF9000F007C117D /* Supporting Files */, 113 | 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */, 114 | 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */, 115 | 74858FAE1ED2DC5600515810 /* AppDelegate.swift */, 116 | 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */, 117 | ); 118 | path = Runner; 119 | sourceTree = ""; 120 | }; 121 | 97C146F11CF9000F007C117D /* Supporting Files */ = { 122 | isa = PBXGroup; 123 | children = ( 124 | ); 125 | name = "Supporting Files"; 126 | sourceTree = ""; 127 | }; 128 | B348084BAE979BBCB2F7D868 /* Frameworks */ = { 129 | isa = PBXGroup; 130 | children = ( 131 | 9346FD54D8FA008F7B2889E1 /* Pods_Runner.framework */, 132 | ); 133 | name = Frameworks; 134 | sourceTree = ""; 135 | }; 136 | /* End PBXGroup section */ 137 | 138 | /* Begin PBXNativeTarget section */ 139 | 97C146ED1CF9000F007C117D /* Runner */ = { 140 | isa = PBXNativeTarget; 141 | buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */; 142 | buildPhases = ( 143 | 73B9C16ADC2863968B853711 /* [CP] Check Pods Manifest.lock */, 144 | 9740EEB61CF901F6004384FC /* Run Script */, 145 | 97C146EA1CF9000F007C117D /* Sources */, 146 | 97C146EB1CF9000F007C117D /* Frameworks */, 147 | 97C146EC1CF9000F007C117D /* Resources */, 148 | 9705A1C41CF9048500538489 /* Embed Frameworks */, 149 | 3B06AD1E1E4923F5004D2608 /* Thin Binary */, 150 | 5E9692F1842720B63BA10C04 /* [CP] Embed Pods Frameworks */, 151 | ); 152 | buildRules = ( 153 | ); 154 | dependencies = ( 155 | ); 156 | name = Runner; 157 | productName = Runner; 158 | productReference = 97C146EE1CF9000F007C117D /* Runner.app */; 159 | productType = "com.apple.product-type.application"; 160 | }; 161 | /* End PBXNativeTarget section */ 162 | 163 | /* Begin PBXProject section */ 164 | 97C146E61CF9000F007C117D /* Project object */ = { 165 | isa = PBXProject; 166 | attributes = { 167 | LastUpgradeCheck = 1020; 168 | ORGANIZATIONNAME = "The Chromium Authors"; 169 | TargetAttributes = { 170 | 97C146ED1CF9000F007C117D = { 171 | CreatedOnToolsVersion = 7.3.1; 172 | LastSwiftMigration = 1100; 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 | 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = { 210 | isa = PBXShellScriptBuildPhase; 211 | buildActionMask = 2147483647; 212 | files = ( 213 | ); 214 | inputPaths = ( 215 | ); 216 | name = "Thin Binary"; 217 | outputPaths = ( 218 | ); 219 | runOnlyForDeploymentPostprocessing = 0; 220 | shellPath = /bin/sh; 221 | shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin"; 222 | }; 223 | 5E9692F1842720B63BA10C04 /* [CP] Embed Pods Frameworks */ = { 224 | isa = PBXShellScriptBuildPhase; 225 | buildActionMask = 2147483647; 226 | files = ( 227 | ); 228 | inputPaths = ( 229 | ); 230 | name = "[CP] Embed Pods Frameworks"; 231 | outputPaths = ( 232 | ); 233 | runOnlyForDeploymentPostprocessing = 0; 234 | shellPath = /bin/sh; 235 | shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n"; 236 | showEnvVarsInLog = 0; 237 | }; 238 | 73B9C16ADC2863968B853711 /* [CP] Check Pods Manifest.lock */ = { 239 | isa = PBXShellScriptBuildPhase; 240 | buildActionMask = 2147483647; 241 | files = ( 242 | ); 243 | inputFileListPaths = ( 244 | ); 245 | inputPaths = ( 246 | "${PODS_PODFILE_DIR_PATH}/Podfile.lock", 247 | "${PODS_ROOT}/Manifest.lock", 248 | ); 249 | name = "[CP] Check Pods Manifest.lock"; 250 | outputFileListPaths = ( 251 | ); 252 | outputPaths = ( 253 | "$(DERIVED_FILE_DIR)/Pods-Runner-checkManifestLockResult.txt", 254 | ); 255 | runOnlyForDeploymentPostprocessing = 0; 256 | shellPath = /bin/sh; 257 | 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"; 258 | showEnvVarsInLog = 0; 259 | }; 260 | 9740EEB61CF901F6004384FC /* Run Script */ = { 261 | isa = PBXShellScriptBuildPhase; 262 | buildActionMask = 2147483647; 263 | files = ( 264 | ); 265 | inputPaths = ( 266 | ); 267 | name = "Run Script"; 268 | outputPaths = ( 269 | ); 270 | runOnlyForDeploymentPostprocessing = 0; 271 | shellPath = /bin/sh; 272 | shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build"; 273 | }; 274 | /* End PBXShellScriptBuildPhase section */ 275 | 276 | /* Begin PBXSourcesBuildPhase section */ 277 | 97C146EA1CF9000F007C117D /* Sources */ = { 278 | isa = PBXSourcesBuildPhase; 279 | buildActionMask = 2147483647; 280 | files = ( 281 | 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */, 282 | 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */, 283 | ); 284 | runOnlyForDeploymentPostprocessing = 0; 285 | }; 286 | /* End PBXSourcesBuildPhase section */ 287 | 288 | /* Begin PBXVariantGroup section */ 289 | 97C146FA1CF9000F007C117D /* Main.storyboard */ = { 290 | isa = PBXVariantGroup; 291 | children = ( 292 | 97C146FB1CF9000F007C117D /* Base */, 293 | ); 294 | name = Main.storyboard; 295 | sourceTree = ""; 296 | }; 297 | 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */ = { 298 | isa = PBXVariantGroup; 299 | children = ( 300 | 97C147001CF9000F007C117D /* Base */, 301 | ); 302 | name = LaunchScreen.storyboard; 303 | sourceTree = ""; 304 | }; 305 | /* End PBXVariantGroup section */ 306 | 307 | /* Begin XCBuildConfiguration section */ 308 | 249021D3217E4FDB00AE95B9 /* Profile */ = { 309 | isa = XCBuildConfiguration; 310 | baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; 311 | buildSettings = { 312 | ALWAYS_SEARCH_USER_PATHS = NO; 313 | CLANG_ANALYZER_NONNULL = YES; 314 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 315 | CLANG_CXX_LIBRARY = "libc++"; 316 | CLANG_ENABLE_MODULES = YES; 317 | CLANG_ENABLE_OBJC_ARC = YES; 318 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 319 | CLANG_WARN_BOOL_CONVERSION = YES; 320 | CLANG_WARN_COMMA = YES; 321 | CLANG_WARN_CONSTANT_CONVERSION = YES; 322 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 323 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 324 | CLANG_WARN_EMPTY_BODY = YES; 325 | CLANG_WARN_ENUM_CONVERSION = YES; 326 | CLANG_WARN_INFINITE_RECURSION = YES; 327 | CLANG_WARN_INT_CONVERSION = YES; 328 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 329 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 330 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 331 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 332 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 333 | CLANG_WARN_STRICT_PROTOTYPES = YES; 334 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 335 | CLANG_WARN_UNREACHABLE_CODE = YES; 336 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 337 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 338 | COPY_PHASE_STRIP = NO; 339 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 340 | ENABLE_NS_ASSERTIONS = NO; 341 | ENABLE_STRICT_OBJC_MSGSEND = YES; 342 | GCC_C_LANGUAGE_STANDARD = gnu99; 343 | GCC_NO_COMMON_BLOCKS = YES; 344 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 345 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 346 | GCC_WARN_UNDECLARED_SELECTOR = YES; 347 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 348 | GCC_WARN_UNUSED_FUNCTION = YES; 349 | GCC_WARN_UNUSED_VARIABLE = YES; 350 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 351 | MTL_ENABLE_DEBUG_INFO = NO; 352 | SDKROOT = iphoneos; 353 | SUPPORTED_PLATFORMS = iphoneos; 354 | TARGETED_DEVICE_FAMILY = "1,2"; 355 | VALIDATE_PRODUCT = YES; 356 | }; 357 | name = Profile; 358 | }; 359 | 249021D4217E4FDB00AE95B9 /* Profile */ = { 360 | isa = XCBuildConfiguration; 361 | baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; 362 | buildSettings = { 363 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 364 | CLANG_ENABLE_MODULES = YES; 365 | CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; 366 | ENABLE_BITCODE = NO; 367 | FRAMEWORK_SEARCH_PATHS = ( 368 | "$(inherited)", 369 | "$(PROJECT_DIR)/Flutter", 370 | ); 371 | INFOPLIST_FILE = Runner/Info.plist; 372 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 373 | LIBRARY_SEARCH_PATHS = ( 374 | "$(inherited)", 375 | "$(PROJECT_DIR)/Flutter", 376 | ); 377 | PRODUCT_BUNDLE_IDENTIFIER = com.flutter.flutterAppUpgradeExample; 378 | PRODUCT_NAME = "$(TARGET_NAME)"; 379 | SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; 380 | SWIFT_VERSION = 5.0; 381 | VERSIONING_SYSTEM = "apple-generic"; 382 | }; 383 | name = Profile; 384 | }; 385 | 97C147031CF9000F007C117D /* Debug */ = { 386 | isa = XCBuildConfiguration; 387 | baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; 388 | buildSettings = { 389 | ALWAYS_SEARCH_USER_PATHS = NO; 390 | CLANG_ANALYZER_NONNULL = YES; 391 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 392 | CLANG_CXX_LIBRARY = "libc++"; 393 | CLANG_ENABLE_MODULES = YES; 394 | CLANG_ENABLE_OBJC_ARC = YES; 395 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 396 | CLANG_WARN_BOOL_CONVERSION = YES; 397 | CLANG_WARN_COMMA = YES; 398 | CLANG_WARN_CONSTANT_CONVERSION = YES; 399 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 400 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 401 | CLANG_WARN_EMPTY_BODY = YES; 402 | CLANG_WARN_ENUM_CONVERSION = YES; 403 | CLANG_WARN_INFINITE_RECURSION = YES; 404 | CLANG_WARN_INT_CONVERSION = YES; 405 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 406 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 407 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 408 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 409 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 410 | CLANG_WARN_STRICT_PROTOTYPES = YES; 411 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 412 | CLANG_WARN_UNREACHABLE_CODE = YES; 413 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 414 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 415 | COPY_PHASE_STRIP = NO; 416 | DEBUG_INFORMATION_FORMAT = dwarf; 417 | ENABLE_STRICT_OBJC_MSGSEND = YES; 418 | ENABLE_TESTABILITY = YES; 419 | GCC_C_LANGUAGE_STANDARD = gnu99; 420 | GCC_DYNAMIC_NO_PIC = NO; 421 | GCC_NO_COMMON_BLOCKS = YES; 422 | GCC_OPTIMIZATION_LEVEL = 0; 423 | GCC_PREPROCESSOR_DEFINITIONS = ( 424 | "DEBUG=1", 425 | "$(inherited)", 426 | ); 427 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 428 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 429 | GCC_WARN_UNDECLARED_SELECTOR = YES; 430 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 431 | GCC_WARN_UNUSED_FUNCTION = YES; 432 | GCC_WARN_UNUSED_VARIABLE = YES; 433 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 434 | MTL_ENABLE_DEBUG_INFO = YES; 435 | ONLY_ACTIVE_ARCH = YES; 436 | SDKROOT = iphoneos; 437 | TARGETED_DEVICE_FAMILY = "1,2"; 438 | }; 439 | name = Debug; 440 | }; 441 | 97C147041CF9000F007C117D /* Release */ = { 442 | isa = XCBuildConfiguration; 443 | baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; 444 | buildSettings = { 445 | ALWAYS_SEARCH_USER_PATHS = NO; 446 | CLANG_ANALYZER_NONNULL = YES; 447 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 448 | CLANG_CXX_LIBRARY = "libc++"; 449 | CLANG_ENABLE_MODULES = YES; 450 | CLANG_ENABLE_OBJC_ARC = YES; 451 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 452 | CLANG_WARN_BOOL_CONVERSION = YES; 453 | CLANG_WARN_COMMA = YES; 454 | CLANG_WARN_CONSTANT_CONVERSION = YES; 455 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 456 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 457 | CLANG_WARN_EMPTY_BODY = YES; 458 | CLANG_WARN_ENUM_CONVERSION = YES; 459 | CLANG_WARN_INFINITE_RECURSION = YES; 460 | CLANG_WARN_INT_CONVERSION = YES; 461 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 462 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 463 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 464 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 465 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 466 | CLANG_WARN_STRICT_PROTOTYPES = YES; 467 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 468 | CLANG_WARN_UNREACHABLE_CODE = YES; 469 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 470 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 471 | COPY_PHASE_STRIP = NO; 472 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 473 | ENABLE_NS_ASSERTIONS = NO; 474 | ENABLE_STRICT_OBJC_MSGSEND = YES; 475 | GCC_C_LANGUAGE_STANDARD = gnu99; 476 | GCC_NO_COMMON_BLOCKS = YES; 477 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 478 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 479 | GCC_WARN_UNDECLARED_SELECTOR = YES; 480 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 481 | GCC_WARN_UNUSED_FUNCTION = YES; 482 | GCC_WARN_UNUSED_VARIABLE = YES; 483 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 484 | MTL_ENABLE_DEBUG_INFO = NO; 485 | SDKROOT = iphoneos; 486 | SUPPORTED_PLATFORMS = iphoneos; 487 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 488 | TARGETED_DEVICE_FAMILY = "1,2"; 489 | VALIDATE_PRODUCT = YES; 490 | }; 491 | name = Release; 492 | }; 493 | 97C147061CF9000F007C117D /* Debug */ = { 494 | isa = XCBuildConfiguration; 495 | baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; 496 | buildSettings = { 497 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 498 | CLANG_ENABLE_MODULES = YES; 499 | CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; 500 | ENABLE_BITCODE = NO; 501 | FRAMEWORK_SEARCH_PATHS = ( 502 | "$(inherited)", 503 | "$(PROJECT_DIR)/Flutter", 504 | ); 505 | INFOPLIST_FILE = Runner/Info.plist; 506 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 507 | LIBRARY_SEARCH_PATHS = ( 508 | "$(inherited)", 509 | "$(PROJECT_DIR)/Flutter", 510 | ); 511 | PRODUCT_BUNDLE_IDENTIFIER = com.flutter.flutterAppUpgradeExample; 512 | PRODUCT_NAME = "$(TARGET_NAME)"; 513 | SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; 514 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 515 | SWIFT_VERSION = 5.0; 516 | VERSIONING_SYSTEM = "apple-generic"; 517 | }; 518 | name = Debug; 519 | }; 520 | 97C147071CF9000F007C117D /* Release */ = { 521 | isa = XCBuildConfiguration; 522 | baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; 523 | buildSettings = { 524 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 525 | CLANG_ENABLE_MODULES = YES; 526 | CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; 527 | ENABLE_BITCODE = NO; 528 | FRAMEWORK_SEARCH_PATHS = ( 529 | "$(inherited)", 530 | "$(PROJECT_DIR)/Flutter", 531 | ); 532 | INFOPLIST_FILE = Runner/Info.plist; 533 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 534 | LIBRARY_SEARCH_PATHS = ( 535 | "$(inherited)", 536 | "$(PROJECT_DIR)/Flutter", 537 | ); 538 | PRODUCT_BUNDLE_IDENTIFIER = com.flutter.flutterAppUpgradeExample; 539 | PRODUCT_NAME = "$(TARGET_NAME)"; 540 | SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; 541 | SWIFT_VERSION = 5.0; 542 | VERSIONING_SYSTEM = "apple-generic"; 543 | }; 544 | name = Release; 545 | }; 546 | /* End XCBuildConfiguration section */ 547 | 548 | /* Begin XCConfigurationList section */ 549 | 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */ = { 550 | isa = XCConfigurationList; 551 | buildConfigurations = ( 552 | 97C147031CF9000F007C117D /* Debug */, 553 | 97C147041CF9000F007C117D /* Release */, 554 | 249021D3217E4FDB00AE95B9 /* Profile */, 555 | ); 556 | defaultConfigurationIsVisible = 0; 557 | defaultConfigurationName = Release; 558 | }; 559 | 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */ = { 560 | isa = XCConfigurationList; 561 | buildConfigurations = ( 562 | 97C147061CF9000F007C117D /* Debug */, 563 | 97C147071CF9000F007C117D /* Release */, 564 | 249021D4217E4FDB00AE95B9 /* Profile */, 565 | ); 566 | defaultConfigurationIsVisible = 0; 567 | defaultConfigurationName = Release; 568 | }; 569 | /* End XCConfigurationList section */ 570 | }; 571 | rootObject = 97C146E61CF9000F007C117D /* Project object */; 572 | } 573 | --------------------------------------------------------------------------------