Commit db8ac2c77221bfda825b2cd4cdbdb33b18725700

Authored by wdn127929
1 parent 1e164fb0

我的发现新版本---30后有弹出更新框,导致重复下载

@@ -14,12 +14,9 @@ if (flutterRoot == null) { @@ -14,12 +14,9 @@ if (flutterRoot == null) {
14 14
15 15
16 16
17 -  
18 -  
19 -  
20 -def flutterVersionCode = "501" 17 +def flutterVersionCode = "100"
21 if (flutterVersionCode == null) { 18 if (flutterVersionCode == null) {
22 - flutterVersionCode = '501' 19 + flutterVersionCode = '100'
23 20
24 21
25 } 22 }
@@ -28,14 +25,33 @@ if (flutterVersionCode == null) { @@ -28,14 +25,33 @@ if (flutterVersionCode == null) {
28 25
29 26
30 27
31 -def flutterVersionName = "5.0.1" 28 +def flutterVersionName = "1.0.1"
32 if (flutterVersionName == null) { 29 if (flutterVersionName == null) {
33 - flutterVersionName = '5.0.1' 30 + flutterVersionName = '1.0.1'
34 31
35 } 32 }
36 33
37 34
38 35
  36 +// def flutterVersionCode = "501"
  37 +// if (flutterVersionCode == null) {
  38 +// flutterVersionCode = '501'
  39 +
  40 +
  41 +// }
  42 +
  43 +
  44 +
  45 +
  46 +
  47 +// def flutterVersionName = "5.0.1"
  48 +// if (flutterVersionName == null) {
  49 +// flutterVersionName = '5.0.1'
  50 +
  51 +// }
  52 +
  53 +
  54 +
39 apply plugin: 'com.android.application' 55 apply plugin: 'com.android.application'
40 apply plugin: 'kotlin-android' 56 apply plugin: 'kotlin-android'
41 apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" 57 apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
@@ -121,12 +121,22 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver { @@ -121,12 +121,22 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver {
121 needRefreshTemp = widget.needReresh; 121 needRefreshTemp = widget.needReresh;
122 _channel.setMethodCallHandler(platformCallHandler); //设置监听 122 _channel.setMethodCallHandler(platformCallHandler); //设置监听
123 123
124 - AzhonAppUpdate.listener(  
125 - // () {  
126 - // needUpdate = false;  
127 - // // print(map['type']);  
128 - // }  
129 - ); 124 + AzhonAppUpdate.listener((map) {
  125 + // needUpdate = false;
  126 + debugPrint(map['type']);
  127 + UserModel usermodel = Provider.of<UserModel>(context, listen: false);
  128 + if (map['type'] == 'downloading') {
  129 + usermodel.downLoading = true;
  130 + } else {
  131 + usermodel.downLoading = false;
  132 + }
  133 + });
  134 +
  135 + // () {
  136 + // needUpdate = false;
  137 + // // print(map['type']);
  138 + // }
  139 +
130 WidgetsBinding.instance.addObserver(this); 140 WidgetsBinding.instance.addObserver(this);
131 141
132 _currIndex = widget.initialIndex; 142 _currIndex = widget.initialIndex;
@@ -232,8 +242,11 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver { @@ -232,8 +242,11 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver {
232 widget.initialIndex == 1 && needRefreshTemp == false) return; 242 widget.initialIndex == 1 && needRefreshTemp == false) return;
233 _initNotification(); 243 _initNotification();
234 Future.delayed(Duration(milliseconds: 30000), () { 244 Future.delayed(Duration(milliseconds: 30000), () {
  245 + //30000
235 ContactModel.getInstance().uploadLocalContact(context); 246 ContactModel.getInstance().uploadLocalContact(context);
236 - if (needUpdate) { 247 + UserModel usermodel = Provider.of<UserModel>(context, listen: false);
  248 +
  249 + if (needUpdate && !usermodel.downLoading) {
237 UpdateModelMy updateModel = new UpdateModelMy(); 250 UpdateModelMy updateModel = new UpdateModelMy();
238 updateModel.checkUpdate(context, (version) { 251 updateModel.checkUpdate(context, (version) {
239 updateModel.showUpdateDialog(context, version); 252 updateModel.showUpdateDialog(context, version);
@@ -1444,6 +1457,7 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver { @@ -1444,6 +1457,7 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver {
1444 if (timerSellerEdate != null) { 1457 if (timerSellerEdate != null) {
1445 timerSellerEdate.cancel(); 1458 timerSellerEdate.cancel();
1446 } 1459 }
  1460 + // AzhonAppUpdate.dispose();
1447 WidgetsBinding.instance.removeObserver(this); 1461 WidgetsBinding.instance.removeObserver(this);
1448 } 1462 }
1449 } 1463 }
@@ -2,6 +2,7 @@ import 'dart:convert'; @@ -2,6 +2,7 @@ import 'dart:convert';
2 2
3 import 'package:common_utils/common_utils.dart'; 3 import 'package:common_utils/common_utils.dart';
4 import 'package:flutter/material.dart'; 4 import 'package:flutter/material.dart';
  5 +import 'package:flutter_app_update/azhon_app_update.dart';
5 import 'package:flutter_ex_widget/ex_text.dart'; 6 import 'package:flutter_ex_widget/ex_text.dart';
6 import 'package:flutter_screenutil/flutter_screenutil.dart'; 7 import 'package:flutter_screenutil/flutter_screenutil.dart';
7 import 'package:fluwx/fluwx.dart'; 8 import 'package:fluwx/fluwx.dart';
@@ -66,6 +67,16 @@ class MyPageState extends State<MyPage> with WidgetsBindingObserver { @@ -66,6 +67,16 @@ class MyPageState extends State<MyPage> with WidgetsBindingObserver {
66 cur_version = "v" + version; 67 cur_version = "v" + version;
67 }); 68 });
68 }); 69 });
  70 + AzhonAppUpdate.listener((map) {
  71 + // needUpdate = false;
  72 + debugPrint(map['type']);
  73 + UserModel usermodel = Provider.of<UserModel>(context, listen: false);
  74 + if (map['type'] == 'downloading') {
  75 + usermodel.downLoading = true;
  76 + } else {
  77 + usermodel.downLoading = false;
  78 + }
  79 + });
69 WidgetsBinding.instance.addPostFrameCallback((_) async { 80 WidgetsBinding.instance.addPostFrameCallback((_) async {
70 ///获取商家时间区间内订单数量 81 ///获取商家时间区间内订单数量
71 _getSellerReserveTotal(); 82 _getSellerReserveTotal();
@@ -93,6 +104,7 @@ class MyPageState extends State<MyPage> with WidgetsBindingObserver { @@ -93,6 +104,7 @@ class MyPageState extends State<MyPage> with WidgetsBindingObserver {
93 void dispose() { 104 void dispose() {
94 // TODO: implement dispose 105 // TODO: implement dispose
95 super.dispose(); 106 super.dispose();
  107 + // AzhonAppUpdate.dispose();
96 EventBus().off('changeStatusColor'); 108 EventBus().off('changeStatusColor');
97 EventBus().off('refreshMySms'); 109 EventBus().off('refreshMySms');
98 } 110 }
@@ -1394,6 +1406,13 @@ class MyPageState extends State<MyPage> with WidgetsBindingObserver { @@ -1394,6 +1406,13 @@ class MyPageState extends State<MyPage> with WidgetsBindingObserver {
1394 VEmptyView(48), 1406 VEmptyView(48),
1395 InkWell( 1407 InkWell(
1396 onTap: () { 1408 onTap: () {
  1409 + UserModel usermodel =
  1410 + Provider.of<UserModel>(context,
  1411 + listen: false);
  1412 + if (usermodel.downLoading) {
  1413 + Utils.showToast("正在后台下载,请您耐心等待...");
  1414 + return;
  1415 + }
1397 if (newVersion) { 1416 if (newVersion) {
1398 UpdateModelMy updateModel = 1417 UpdateModelMy updateModel =
1399 new UpdateModelMy(); 1418 new UpdateModelMy();
@@ -36,8 +36,8 @@ class UpdateModelMy { @@ -36,8 +36,8 @@ class UpdateModelMy {
36 "yjd.apk", 36 "yjd.apk",
37 "ic_launcher", 37 "ic_launcher",
38 // "1.支持Android M N O P Q\n2.支持自定义下载过程\n3.支持 设备>=Android M 动态权限的申请\n4.支持通知栏进度条展示\n5.支持文字国际化", 38 // "1.支持Android M N O P Q\n2.支持自定义下载过程\n3.支持 设备>=Android M 动态权限的申请\n4.支持通知栏进度条展示\n5.支持文字国际化",
39 - // iOSUrl:  
40 - // 'itms-apps://itunes.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=1510697490', 39 +
  40 + 'itms-apps://itunes.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=1510697490',
41 // showiOSDialog: showiOSDialog, 41 // showiOSDialog: showiOSDialog,
42 ); 42 );
43 AzhonAppUpdate.update(model).then((value) => print(value)); 43 AzhonAppUpdate.update(model).then((value) => print(value));
@@ -33,6 +33,7 @@ class UserModel with ChangeNotifier { @@ -33,6 +33,7 @@ class UserModel with ChangeNotifier {
33 // bool accountLogin = false; 33 // bool accountLogin = false;
34 34
35 List<Setmeal> justSelData = []; 35 List<Setmeal> justSelData = [];
  36 + bool downLoading = false;
36 37
37 // User get user => _user; 38 // User get user => _user;
38 User get user { 39 User get user {
@@ -446,7 +446,7 @@ packages: @@ -446,7 +446,7 @@ packages:
446 name: flutter_app_update 446 name: flutter_app_update
447 url: "https://pub.flutter-io.cn" 447 url: "https://pub.flutter-io.cn"
448 source: hosted 448 source: hosted
449 - version: "0.0.2" 449 + version: "3.0.2"
450 flutter_blurhash: 450 flutter_blurhash:
451 dependency: transitive 451 dependency: transitive
452 description: 452 description:
@@ -159,7 +159,8 @@ dependencies: @@ -159,7 +159,8 @@ dependencies:
159 #图片压缩 159 #图片压缩
160 flutter_native_image: ^0.0.6+1 160 flutter_native_image: ^0.0.6+1
161 #更新apk 161 #更新apk
162 - flutter_app_update: ^0.0.2 162 + # flutter_app_update: ^0.0.2
  163 + flutter_app_update: ^3.0.2
163 # flutter_app_update: ^1.0.0 164 # flutter_app_update: ^1.0.0
164 flutter_staggered_grid_view: ^0.4.1 165 flutter_staggered_grid_view: ^0.4.1
165 # webview 166 # webview