Commit 3c42db19845401f1a19ce596f1347f48fa6b178a

Authored by gaiyaguang
1 parent c59625c7

flutter2.0集成腾讯bugly

1 PODS: 1 PODS:
2 - audioplayers (0.0.1): 2 - audioplayers (0.0.1):
3 - Flutter 3 - Flutter
  4 + - Bugly (2.5.4)
4 - connectivity (0.0.1): 5 - connectivity (0.0.1):
5 - Flutter 6 - Flutter
6 - Reachability 7 - Reachability
7 - connectivity_macos (0.0.1): 8 - connectivity_macos (0.0.1):
8 - Flutter 9 - Flutter
9 - Flutter (1.0.0) 10 - Flutter (1.0.0)
  11 + - flutter_bugly (0.0.1):
  12 + - Bugly
  13 + - Flutter
10 - flutter_statusbarcolor (0.0.1): 14 - flutter_statusbarcolor (0.0.1):
11 - Flutter 15 - Flutter
12 - fluttertoast (0.0.2): 16 - fluttertoast (0.0.2):
@@ -56,6 +60,7 @@ DEPENDENCIES: @@ -56,6 +60,7 @@ DEPENDENCIES:
56 - connectivity (from `.symlinks/plugins/connectivity/ios`) 60 - connectivity (from `.symlinks/plugins/connectivity/ios`)
57 - connectivity_macos (from `.symlinks/plugins/connectivity_macos/ios`) 61 - connectivity_macos (from `.symlinks/plugins/connectivity_macos/ios`)
58 - Flutter (from `Flutter`) 62 - Flutter (from `Flutter`)
  63 + - flutter_bugly (from `.symlinks/plugins/flutter_bugly/ios`)
59 - flutter_statusbarcolor (from `.symlinks/plugins/flutter_statusbarcolor/ios`) 64 - flutter_statusbarcolor (from `.symlinks/plugins/flutter_statusbarcolor/ios`)
60 - fluttertoast (from `.symlinks/plugins/fluttertoast/ios`) 65 - fluttertoast (from `.symlinks/plugins/fluttertoast/ios`)
61 - fluwx (from `.symlinks/plugins/fluwx/ios`) 66 - fluwx (from `.symlinks/plugins/fluwx/ios`)
@@ -75,6 +80,7 @@ DEPENDENCIES: @@ -75,6 +80,7 @@ DEPENDENCIES:
75 80
76 SPEC REPOS: 81 SPEC REPOS:
77 https://github.com/CocoaPods/Specs.git: 82 https://github.com/CocoaPods/Specs.git:
  83 + - Bugly
78 - FMDB 84 - FMDB
79 - JCore 85 - JCore
80 - JPush 86 - JPush
@@ -90,6 +96,8 @@ EXTERNAL SOURCES: @@ -90,6 +96,8 @@ EXTERNAL SOURCES:
90 :path: ".symlinks/plugins/connectivity_macos/ios" 96 :path: ".symlinks/plugins/connectivity_macos/ios"
91 Flutter: 97 Flutter:
92 :path: Flutter 98 :path: Flutter
  99 + flutter_bugly:
  100 + :path: ".symlinks/plugins/flutter_bugly/ios"
93 flutter_statusbarcolor: 101 flutter_statusbarcolor:
94 :path: ".symlinks/plugins/flutter_statusbarcolor/ios" 102 :path: ".symlinks/plugins/flutter_statusbarcolor/ios"
95 fluttertoast: 103 fluttertoast:
@@ -125,9 +133,11 @@ EXTERNAL SOURCES: @@ -125,9 +133,11 @@ EXTERNAL SOURCES:
125 133
126 SPEC CHECKSUMS: 134 SPEC CHECKSUMS:
127 audioplayers: 84f968cea3f2deab00ec4f8ff53358b3c0b3992c 135 audioplayers: 84f968cea3f2deab00ec4f8ff53358b3c0b3992c
  136 + Bugly: 4edda9bb0e3017fd453612189069757195fa23ca
128 connectivity: 6e94255659cc86dcbef1d452ad3e0491bb1b3e75 137 connectivity: 6e94255659cc86dcbef1d452ad3e0491bb1b3e75
129 connectivity_macos: e2e9731b6b22dda39eb1b128f6969d574460e191 138 connectivity_macos: e2e9731b6b22dda39eb1b128f6969d574460e191
130 Flutter: 0e3d915762c693b495b44d77113d4970485de6ec 139 Flutter: 0e3d915762c693b495b44d77113d4970485de6ec
  140 + flutter_bugly: c9800f4d5bc5bdc27ffdde3417a26ba44266e0c3
131 flutter_statusbarcolor: 8afb1071ed8c58be929f1e32b36c629771fd2259 141 flutter_statusbarcolor: 8afb1071ed8c58be929f1e32b36c629771fd2259
132 fluttertoast: b644586ef3b16f67fae9a1f8754cef6b2d6b634b 142 fluttertoast: b644586ef3b16f67fae9a1f8754cef6b2d6b634b
133 fluwx: 07a55ed66bf3a4961e836a2a411b02dcada32902 143 fluwx: 07a55ed66bf3a4961e836a2a411b02dcada32902
@@ -2,6 +2,7 @@ @@ -2,6 +2,7 @@
2 import 'package:dio/dio.dart'; 2 import 'package:dio/dio.dart';
3 import 'package:fluro/fluro.dart'; 3 import 'package:fluro/fluro.dart';
4 import 'package:flutter/material.dart'; 4 import 'package:flutter/material.dart';
  5 +import 'package:flutter_bugly/flutter_bugly.dart';
5 import 'package:flutter_easyrefresh/ball_pulse_footer.dart'; 6 import 'package:flutter_easyrefresh/ball_pulse_footer.dart';
6 import 'package:flutter_easyrefresh/easy_refresh.dart'; 7 import 'package:flutter_easyrefresh/easy_refresh.dart';
7 import 'package:flutter_easyrefresh/material_header.dart'; 8 import 'package:flutter_easyrefresh/material_header.dart';
@@ -22,24 +23,27 @@ import 'utils/log_util.dart'; @@ -22,24 +23,27 @@ import 'utils/log_util.dart';
22 import 'package:flutter/services.dart'; 23 import 'package:flutter/services.dart';
23 24
24 Future<void> main() async { 25 Future<void> main() async {
25 - Router router = Router();  
26 - Routes.configureRoutes(router);  
27 - App.router = router;  
28 - App.setupLocator();  
29 - LogUtil.init(isDebug: true, tag: 'ONE_KEY');  
30 - Provider.debugCheckInvalidValueType = null;  
31 - await initializeDateFormatting();  
32 - runApp(MultiProvider(  
33 - providers: [  
34 - ChangeNotifierProvider<UserModel>(  
35 - create: (_) => UserModel(),  
36 - ),  
37 - ChangeNotifierProvider<MessageDialogModel>(  
38 - create: (_) => MessageDialogModel()..init(),  
39 - )  
40 - ],  
41 - child: MyApp(),  
42 - )); 26 + FlutterBugly.postCatchedException(() async {
  27 + Router router = Router();
  28 + Routes.configureRoutes(router);
  29 + App.router = router;
  30 + App.setupLocator();
  31 + LogUtil.init(isDebug: true, tag: 'ONE_KEY');
  32 + Provider.debugCheckInvalidValueType = null;
  33 + await initializeDateFormatting();
  34 + runApp(MultiProvider(
  35 + providers: [
  36 + ChangeNotifierProvider<UserModel>(
  37 + create: (_) => UserModel(),
  38 + ),
  39 + ChangeNotifierProvider<MessageDialogModel>(
  40 + create: (_) => MessageDialogModel()..init(),
  41 + )
  42 + ],
  43 + child: MyApp(),
  44 + ));
  45 + FlutterBugly.init(androidAppId: "f71a313f42",iOSAppId: "3089e4587e");
  46 + });
43 } 47 }
44 48
45 class MyApp extends StatefulWidget { 49 class MyApp extends StatefulWidget {
@@ -22,6 +22,7 @@ class MyPage extends StatefulWidget{ @@ -22,6 +22,7 @@ class MyPage extends StatefulWidget{
22 class MyPageState extends State<MyPage>{ 22 class MyPageState extends State<MyPage>{
23 23
24 String cur_version=""; 24 String cur_version="";
  25 + bool newVersion=false;
25 26
26 @override 27 @override
27 void initState() { 28 void initState() {
@@ -89,6 +90,17 @@ class MyPageState extends State<MyPage>{ @@ -89,6 +90,17 @@ class MyPageState extends State<MyPage>{
89 children: <Widget>[ 90 children: <Widget>[
90 Text("版本更新",style: TextStyle(fontSize: ScreenUtil().setSp(30),color: MyColours.color_353535),), 91 Text("版本更新",style: TextStyle(fontSize: ScreenUtil().setSp(30),color: MyColours.color_353535),),
91 Spacer(), 92 Spacer(),
  93 + newVersion?Container(
  94 + width: ScreenUtil().setWidth(120),
  95 + height: ScreenUtil().setWidth(34),
  96 + decoration: BoxDecoration(
  97 + color: MyColours.color_E14553,
  98 + borderRadius: BorderRadius.all(Radius.circular(ScreenUtil().setWidth(6))),
  99 + ),
  100 + child: Center(
  101 + child: Text("发现新版本",style: TextStyle(fontSize: ScreenUtil().setSp(24),color: MyColours.color_ffffff),),
  102 + ),
  103 + ):
92 Text(cur_version,style: TextStyle(fontSize: ScreenUtil().setSp(28),color: MyColours.color_666666),), 104 Text(cur_version,style: TextStyle(fontSize: ScreenUtil().setSp(28),color: MyColours.color_666666),),
93 HEmptyView(20), 105 HEmptyView(20),
94 Image.asset("assets/arr_right_gray.png",width: ScreenUtil().setWidth(14),height: ScreenUtil().setWidth(22),) 106 Image.asset("assets/arr_right_gray.png",width: ScreenUtil().setWidth(14),height: ScreenUtil().setWidth(22),)
@@ -31,9 +31,9 @@ class UpdateModel { @@ -31,9 +31,9 @@ class UpdateModel {
31 } 31 }
32 32
33 //版本更新弹框 33 //版本更新弹框
34 - showUpdateDialog(BuildContext context, Version version) { 34 + showUpdateDialog(BuildContext pageContext, Version version) {
35 showDialog( 35 showDialog(
36 - context: context, 36 + context: pageContext,
37 builder: (context) { 37 builder: (context) {
38 Widget widget = Container( 38 Widget widget = Container(
39 decoration: BoxDecoration( 39 decoration: BoxDecoration(
@@ -96,7 +96,7 @@ class UpdateModel { @@ -96,7 +96,7 @@ class UpdateModel {
96 onTap: () { 96 onTap: () {
97 Navigator.of(context).pop(); 97 Navigator.of(context).pop();
98 if (Platform.isAndroid) { 98 if (Platform.isAndroid) {
99 - downloadApk(context, version.file_url); 99 + downloadApk(pageContext, version.file_url);
100 } else { 100 } else {
101 InstallPlugin.gotoAppStore( 101 InstallPlugin.gotoAppStore(
102 "itms-apps://itunes.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=1510697490"); 102 "itms-apps://itunes.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=1510697490");
@@ -141,10 +141,20 @@ class UpdateModel { @@ -141,10 +141,20 @@ class UpdateModel {
141 if (permissions[PermissionGroup.storage] == PermissionStatus.granted) { 141 if (permissions[PermissionGroup.storage] == PermissionStatus.granted) {
142 final dir = await getExternalStorageDirectory(); 142 final dir = await getExternalStorageDirectory();
143 String savePath = dir.path + "/one_key"; 143 String savePath = dir.path + "/one_key";
  144 + Directory directory=new Directory(savePath);
  145 + if(directory.existsSync()){//删除历史apk
  146 + final List<FileSystemEntity> files=directory.listSync();
  147 + for(FileSystemEntity file in files){
  148 + file.deleteSync();
  149 + }
  150 + }
  151 + showDownloadProgress(context);
144 DioUtil().download(file_url, savePath, onProgress: (received, total) { 152 DioUtil().download(file_url, savePath, onProgress: (received, total) {
145 - int progress = ((received / total) * 100).round();  
146 - _progress = progress;  
147 - _setState(() {}); 153 + if(_progress!=100){
  154 + int progress = ((received / total) * 100).round();
  155 + _progress = progress;
  156 + _setState(() {});
  157 + }
148 if (received == total) { 158 if (received == total) {
149 //下载完成 159 //下载完成
150 InstallPlugin.installApk(savePath, "com.naji.one_key"); 160 InstallPlugin.installApk(savePath, "com.naji.one_key");
@@ -154,15 +164,15 @@ class UpdateModel { @@ -154,15 +164,15 @@ class UpdateModel {
154 } 164 }
155 165
156 //显示下载进度条 166 //显示下载进度条
157 - Function showDownloadProgress(BuildContext context) { 167 + showDownloadProgress(BuildContext context) {
158 showDialog( 168 showDialog(
159 context: context, 169 context: context,
160 barrierDismissible: false, 170 barrierDismissible: false,
161 - builder: (context) { 171 + builder: (ct) {
162 return AlertDialog( 172 return AlertDialog(
163 content: StatefulBuilder(builder: (context, setState) { 173 content: StatefulBuilder(builder: (context, setState) {
164 - if (_progress == 100) {  
165 - Navigator.of(context).pop(); 174 + if (_progress==100) {
  175 + Navigator.of(ct).pop();
166 } 176 }
167 _setState = setState; 177 _setState = setState;
168 return Column( 178 return Column(
@@ -177,6 +187,5 @@ class UpdateModel { @@ -177,6 +187,5 @@ class UpdateModel {
177 ); 187 );
178 })); 188 }));
179 }); 189 });
180 - return _setState;  
181 } 190 }
182 } 191 }
@@ -15,6 +15,7 @@ class MyColours { @@ -15,6 +15,7 @@ class MyColours {
15 static const Color color_2bb5b7=Color(0xff2BB5B7); 15 static const Color color_2bb5b7=Color(0xff2BB5B7);
16 static const Color color_26000000=Color(0x26000000); 16 static const Color color_26000000=Color(0x26000000);
17 static const Color color_d93535=Color(0xffD93535); 17 static const Color color_d93535=Color(0xffD93535);
  18 + static const Color color_E14553=Color(0xffE14553);
18 static const Color color_131313=Color(0xff131313); 19 static const Color color_131313=Color(0xff131313);
19 static const Color color_2e000000=Color(0x2e000000); 20 static const Color color_2e000000=Color(0x2e000000);
20 static const Color color_14000000=Color(0x14000000); 21 static const Color color_14000000=Color(0x14000000);
  1 +import 'package:flutter/material.dart';
  2 +import 'package:flutter_screenutil/flutter_screenutil.dart';
  3 +import 'package:one_key/res/colors.dart';
  4 +import 'package:one_key/widgets/v_empty_view.dart';
  5 +
  6 +class ErrorPage extends StatefulWidget{
  7 +
  8 + final VoidCallback callback;
  9 +
  10 + const ErrorPage({Key key, this.callback}) : super(key: key);
  11 +
  12 + @override
  13 + State<StatefulWidget> createState() {
  14 + // TODO: implement createState
  15 + return new ErrorPageState();
  16 + }
  17 +
  18 +}
  19 +
  20 +class ErrorPageState extends State<ErrorPage>{
  21 + @override
  22 + Widget build(BuildContext context) {
  23 + // TODO: implement build
  24 + return Container(
  25 + width: double.infinity,
  26 + height: double.infinity,
  27 + child: Center(
  28 + child: Column(
  29 + children: <Widget>[
  30 + Image.asset("assets/bg_error",width: ScreenUtil().setWidth(311),height: ScreenUtil().setWidth(215),),
  31 + VEmptyView(40),
  32 + Text("哎呀~网络好像走失了呢",style: TextStyle(fontSize: ScreenUtil().setSp(32),color: MyColours.color_353535),),
  33 + VEmptyView(20),
  34 + widget.callback!=null?GestureDetector(
  35 + onTap: widget.callback,
  36 + child: Container(
  37 + width: ScreenUtil().setWidth(148),
  38 + height: ScreenUtil().setWidth(58),
  39 + decoration: BoxDecoration(
  40 + color: MyColours.color_2bb5b7,
  41 + borderRadius: BorderRadius.all(Radius.circular(ScreenUtil().setWidth(12)))
  42 + ),
  43 + child: Center(
  44 + child: Text("点击刷新",style: TextStyle(fontSize: ScreenUtil().setSp(30),color: MyColours.color_ffffff),),
  45 + ),
  46 + ),
  47 + ):Container()
  48 + ],
  49 + ),
  50 + ),
  51 + );
  52 + }
  53 +
  54 +}
@@ -237,6 +237,13 @@ packages: @@ -237,6 +237,13 @@ packages:
237 description: flutter 237 description: flutter
238 source: sdk 238 source: sdk
239 version: "0.0.0" 239 version: "0.0.0"
  240 + flutter_bugly:
  241 + dependency: "direct main"
  242 + description:
  243 + name: flutter_bugly
  244 + url: "https://pub.flutter-io.cn"
  245 + source: hosted
  246 + version: "0.2.8"
240 flutter_cache_manager: 247 flutter_cache_manager:
241 dependency: transitive 248 dependency: transitive
242 description: 249 description:
@@ -56,7 +56,7 @@ dependencies: @@ -56,7 +56,7 @@ dependencies:
56 # 极光推送 56 # 极光推送
57 jpush_flutter: 0.5.3 57 jpush_flutter: 0.5.3
58 # Bugly 58 # Bugly
59 -# flutter_bugly: ^0.2.8 59 + flutter_bugly: ^0.2.8
60 # 设置状态栏颜色 60 # 设置状态栏颜色
61 flutter_statusbarcolor: ^0.2.3 61 flutter_statusbarcolor: ^0.2.3
62 # 语音播放器 62 # 语音播放器