|
|
@@ -1,8 +1,12 @@
|
|
|
+import 'package:common_pub/common_pub_platform_interface.dart';
|
|
|
+import 'package:flutter/material.dart';
|
|
|
import 'package:get/get.dart';
|
|
|
+import 'package:package_info_plus/package_info_plus.dart';
|
|
|
import 'api.dart';
|
|
|
import 'app.dart';
|
|
|
+import 'package:common_pub/pb.dart' as pb;
|
|
|
|
|
|
-Future<void> initBeforeApp()async{
|
|
|
+Future<void> initBeforeApp() async {
|
|
|
// final flavor = await getFlavor();
|
|
|
// if(flavor=='dev'){
|
|
|
// GlobalVar.apiHost='totapi-lc.beswell.com';
|
|
|
@@ -16,14 +20,27 @@ Future<void> initBeforeApp()async{
|
|
|
// }
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-Future<void> allInit()async{
|
|
|
-
|
|
|
-
|
|
|
+Future<void> allInit() async {
|
|
|
Get.put<AppService>(await AppService().init());
|
|
|
Get.put<ApiService>(await ApiService().init());
|
|
|
|
|
|
-
|
|
|
-}
|
|
|
+ ApiService api = Get.find();
|
|
|
+ final packageInfo = await PackageInfo.fromPlatform();
|
|
|
+ final appVersion = packageInfo.version;
|
|
|
+ final updateInfo = await api.stub
|
|
|
+ .toGetUpdateVersion(pb.ToGetUpdateVersionRequest(vCode: appVersion));
|
|
|
+
|
|
|
+ if (updateInfo.needUpdate) {
|
|
|
+ final pStream =
|
|
|
+ CommonPubPlatform.instance.updateApp(updateInfo.vUrl, updateInfo.vCode);
|
|
|
+ final value = 0.0.obs;
|
|
|
+ value.bindStream(pStream);
|
|
|
+
|
|
|
+ await Get.dialog(
|
|
|
+ AlertDialog(
|
|
|
+ title: const Text('软件更新'),
|
|
|
+ content: Obx(() => LinearProgressIndicator(value: value.value)),
|
|
|
+ ),
|
|
|
+ barrierDismissible: false);
|
|
|
+ }
|
|
|
+}
|