Commit 3c42db19845401f1a19ce596f1347f48fa6b178a

Authored by gaiyaguang
1 parent c59625c7

flutter2.0集成腾讯bugly

PODS:
- audioplayers (0.0.1):
- Flutter
- Bugly (2.5.4)
- connectivity (0.0.1):
- Flutter
- Reachability
- connectivity_macos (0.0.1):
- Flutter
- Flutter (1.0.0)
- flutter_bugly (0.0.1):
- Bugly
- Flutter
- flutter_statusbarcolor (0.0.1):
- Flutter
- fluttertoast (0.0.2):
... ... @@ -56,6 +60,7 @@ DEPENDENCIES:
- connectivity (from `.symlinks/plugins/connectivity/ios`)
- connectivity_macos (from `.symlinks/plugins/connectivity_macos/ios`)
- Flutter (from `Flutter`)
- flutter_bugly (from `.symlinks/plugins/flutter_bugly/ios`)
- flutter_statusbarcolor (from `.symlinks/plugins/flutter_statusbarcolor/ios`)
- fluttertoast (from `.symlinks/plugins/fluttertoast/ios`)
- fluwx (from `.symlinks/plugins/fluwx/ios`)
... ... @@ -75,6 +80,7 @@ DEPENDENCIES:
SPEC REPOS:
https://github.com/CocoaPods/Specs.git:
- Bugly
- FMDB
- JCore
- JPush
... ... @@ -90,6 +96,8 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/connectivity_macos/ios"
Flutter:
:path: Flutter
flutter_bugly:
:path: ".symlinks/plugins/flutter_bugly/ios"
flutter_statusbarcolor:
:path: ".symlinks/plugins/flutter_statusbarcolor/ios"
fluttertoast:
... ... @@ -125,9 +133,11 @@ EXTERNAL SOURCES:
SPEC CHECKSUMS:
audioplayers: 84f968cea3f2deab00ec4f8ff53358b3c0b3992c
Bugly: 4edda9bb0e3017fd453612189069757195fa23ca
connectivity: 6e94255659cc86dcbef1d452ad3e0491bb1b3e75
connectivity_macos: e2e9731b6b22dda39eb1b128f6969d574460e191
Flutter: 0e3d915762c693b495b44d77113d4970485de6ec
flutter_bugly: c9800f4d5bc5bdc27ffdde3417a26ba44266e0c3
flutter_statusbarcolor: 8afb1071ed8c58be929f1e32b36c629771fd2259
fluttertoast: b644586ef3b16f67fae9a1f8754cef6b2d6b634b
fluwx: 07a55ed66bf3a4961e836a2a411b02dcada32902
... ...
... ... @@ -2,6 +2,7 @@
import 'package:dio/dio.dart';
import 'package:fluro/fluro.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bugly/flutter_bugly.dart';
import 'package:flutter_easyrefresh/ball_pulse_footer.dart';
import 'package:flutter_easyrefresh/easy_refresh.dart';
import 'package:flutter_easyrefresh/material_header.dart';
... ... @@ -22,24 +23,27 @@ import 'utils/log_util.dart';
import 'package:flutter/services.dart';
Future<void> main() async {
Router router = Router();
Routes.configureRoutes(router);
App.router = router;
App.setupLocator();
LogUtil.init(isDebug: true, tag: 'ONE_KEY');
Provider.debugCheckInvalidValueType = null;
await initializeDateFormatting();
runApp(MultiProvider(
providers: [
ChangeNotifierProvider<UserModel>(
create: (_) => UserModel(),
),
ChangeNotifierProvider<MessageDialogModel>(
create: (_) => MessageDialogModel()..init(),
)
],
child: MyApp(),
));
FlutterBugly.postCatchedException(() async {
Router router = Router();
Routes.configureRoutes(router);
App.router = router;
App.setupLocator();
LogUtil.init(isDebug: true, tag: 'ONE_KEY');
Provider.debugCheckInvalidValueType = null;
await initializeDateFormatting();
runApp(MultiProvider(
providers: [
ChangeNotifierProvider<UserModel>(
create: (_) => UserModel(),
),
ChangeNotifierProvider<MessageDialogModel>(
create: (_) => MessageDialogModel()..init(),
)
],
child: MyApp(),
));
FlutterBugly.init(androidAppId: "f71a313f42",iOSAppId: "3089e4587e");
});
}
class MyApp extends StatefulWidget {
... ...
... ... @@ -22,6 +22,7 @@ class MyPage extends StatefulWidget{
class MyPageState extends State<MyPage>{
String cur_version="";
bool newVersion=false;
@override
void initState() {
... ... @@ -89,6 +90,17 @@ class MyPageState extends State<MyPage>{
children: <Widget>[
Text("版本更新",style: TextStyle(fontSize: ScreenUtil().setSp(30),color: MyColours.color_353535),),
Spacer(),
newVersion?Container(
width: ScreenUtil().setWidth(120),
height: ScreenUtil().setWidth(34),
decoration: BoxDecoration(
color: MyColours.color_E14553,
borderRadius: BorderRadius.all(Radius.circular(ScreenUtil().setWidth(6))),
),
child: Center(
child: Text("发现新版本",style: TextStyle(fontSize: ScreenUtil().setSp(24),color: MyColours.color_ffffff),),
),
):
Text(cur_version,style: TextStyle(fontSize: ScreenUtil().setSp(28),color: MyColours.color_666666),),
HEmptyView(20),
Image.asset("assets/arr_right_gray.png",width: ScreenUtil().setWidth(14),height: ScreenUtil().setWidth(22),)
... ...
... ... @@ -31,9 +31,9 @@ class UpdateModel {
}
//版本更新弹框
showUpdateDialog(BuildContext context, Version version) {
showUpdateDialog(BuildContext pageContext, Version version) {
showDialog(
context: context,
context: pageContext,
builder: (context) {
Widget widget = Container(
decoration: BoxDecoration(
... ... @@ -96,7 +96,7 @@ class UpdateModel {
onTap: () {
Navigator.of(context).pop();
if (Platform.isAndroid) {
downloadApk(context, version.file_url);
downloadApk(pageContext, version.file_url);
} else {
InstallPlugin.gotoAppStore(
"itms-apps://itunes.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=1510697490");
... ... @@ -141,10 +141,20 @@ class UpdateModel {
if (permissions[PermissionGroup.storage] == PermissionStatus.granted) {
final dir = await getExternalStorageDirectory();
String savePath = dir.path + "/one_key";
Directory directory=new Directory(savePath);
if(directory.existsSync()){//删除历史apk
final List<FileSystemEntity> files=directory.listSync();
for(FileSystemEntity file in files){
file.deleteSync();
}
}
showDownloadProgress(context);
DioUtil().download(file_url, savePath, onProgress: (received, total) {
int progress = ((received / total) * 100).round();
_progress = progress;
_setState(() {});
if(_progress!=100){
int progress = ((received / total) * 100).round();
_progress = progress;
_setState(() {});
}
if (received == total) {
//下载完成
InstallPlugin.installApk(savePath, "com.naji.one_key");
... ... @@ -154,15 +164,15 @@ class UpdateModel {
}
//显示下载进度条
Function showDownloadProgress(BuildContext context) {
showDownloadProgress(BuildContext context) {
showDialog(
context: context,
barrierDismissible: false,
builder: (context) {
builder: (ct) {
return AlertDialog(
content: StatefulBuilder(builder: (context, setState) {
if (_progress == 100) {
Navigator.of(context).pop();
if (_progress==100) {
Navigator.of(ct).pop();
}
_setState = setState;
return Column(
... ... @@ -177,6 +187,5 @@ class UpdateModel {
);
}));
});
return _setState;
}
}
... ...
... ... @@ -15,6 +15,7 @@ class MyColours {
static const Color color_2bb5b7=Color(0xff2BB5B7);
static const Color color_26000000=Color(0x26000000);
static const Color color_d93535=Color(0xffD93535);
static const Color color_E14553=Color(0xffE14553);
static const Color color_131313=Color(0xff131313);
static const Color color_2e000000=Color(0x2e000000);
static const Color color_14000000=Color(0x14000000);
... ...
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:one_key/res/colors.dart';
import 'package:one_key/widgets/v_empty_view.dart';
class ErrorPage extends StatefulWidget{
final VoidCallback callback;
const ErrorPage({Key key, this.callback}) : super(key: key);
@override
State<StatefulWidget> createState() {
// TODO: implement createState
return new ErrorPageState();
}
}
class ErrorPageState extends State<ErrorPage>{
@override
Widget build(BuildContext context) {
// TODO: implement build
return Container(
width: double.infinity,
height: double.infinity,
child: Center(
child: Column(
children: <Widget>[
Image.asset("assets/bg_error",width: ScreenUtil().setWidth(311),height: ScreenUtil().setWidth(215),),
VEmptyView(40),
Text("哎呀~网络好像走失了呢",style: TextStyle(fontSize: ScreenUtil().setSp(32),color: MyColours.color_353535),),
VEmptyView(20),
widget.callback!=null?GestureDetector(
onTap: widget.callback,
child: Container(
width: ScreenUtil().setWidth(148),
height: ScreenUtil().setWidth(58),
decoration: BoxDecoration(
color: MyColours.color_2bb5b7,
borderRadius: BorderRadius.all(Radius.circular(ScreenUtil().setWidth(12)))
),
child: Center(
child: Text("点击刷新",style: TextStyle(fontSize: ScreenUtil().setSp(30),color: MyColours.color_ffffff),),
),
),
):Container()
],
),
),
);
}
}
\ No newline at end of file
... ...
... ... @@ -237,6 +237,13 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
flutter_bugly:
dependency: "direct main"
description:
name: flutter_bugly
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.2.8"
flutter_cache_manager:
dependency: transitive
description:
... ...
... ... @@ -56,7 +56,7 @@ dependencies:
# 极光推送
jpush_flutter: 0.5.3
# Bugly
# flutter_bugly: ^0.2.8
flutter_bugly: ^0.2.8
# 设置状态栏颜色
flutter_statusbarcolor: ^0.2.3
# 语音播放器
... ...