From ef4937ad6dc6f1c2fa4a4413ac06ee451587f505 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=83=A1=E5=A4=A9?= Date: Wed, 26 Jul 2023 17:17:27 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0sentry=E7=9B=91=E6=8E=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/global.dart | 3 ++- lib/main.dart | 41 +++++++++++++++++++++++++---------------- lib/utils/update.dart | 3 +++ pubspec.lock | 14 +++++++++++--- pubspec.yaml | 4 ++-- 5 files changed, 43 insertions(+), 22 deletions(-) diff --git a/lib/global.dart b/lib/global.dart index 73b2d02..54aa011 100644 --- a/lib/global.dart +++ b/lib/global.dart @@ -12,12 +12,13 @@ class Global { static Future init() async { // 运行初始 WidgetsFlutterBinding.ensureInitialized(); + // 设备方向 await SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]); // 调整系统UI 因为appBar会覆盖这个设置 所以换了个地方设置 // setSystemUi(); - // 初始换easyLoading + // 初始化easyLoading Loading(); await Get.putAsync(() => StorageService().init()); diff --git a/lib/main.dart b/lib/main.dart index f6bc7a7..0865bce 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,4 +1,3 @@ -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_easyloading/flutter_easyloading.dart'; @@ -11,10 +10,20 @@ import 'package:news_getx/theme/app_theme.dart'; import 'package:news_getx/translations/app_translations.dart'; import 'package:pull_to_refresh/pull_to_refresh.dart'; import 'package:flutter_localizations/flutter_localizations.dart'; +import 'package:sentry_flutter/sentry_flutter.dart'; Future main() async { await Global.init(); - runApp(const MyApp()); + + await SentryFlutter.init( + (options) { + options.dsn = "https://acac4fdb2abc486a9f7c64558f27d85e@o4505594886356992.ingest.sentry.io/4505594892124160"; + if (ConfigService.to.isRelease) { + options.tracesSampleRate = 1.0; + } + }, + appRunner: () => runApp(const MyApp()), + ); } class MyApp extends StatelessWidget { @@ -28,21 +37,19 @@ class MyApp extends StatelessWidget { // 如果不把这歌参数设为true 那么column就不会随着软键盘而变化 // useInheritedMediaQuery: true, builder: (BuildContext context, Widget? child) { - var app = GetMaterialApp( title: 'News', debugShowCheckedModeBanner: false, theme: AppTheme.light.copyWith( appBarTheme: AppBarTheme( - systemOverlayStyle: SystemUiOverlayStyle( - statusBarColor: Colors.transparent, - statusBarBrightness: Brightness.light, - statusBarIconBrightness: Brightness.dark, - systemNavigationBarDividerColor: Colors.transparent, - systemNavigationBarColor: Colors.white, - systemNavigationBarIconBrightness: Brightness.dark, - ) - ), + systemOverlayStyle: SystemUiOverlayStyle( + statusBarColor: Colors.transparent, + statusBarBrightness: Brightness.light, + statusBarIconBrightness: Brightness.dark, + systemNavigationBarDividerColor: Colors.transparent, + systemNavigationBarColor: Colors.white, + systemNavigationBarIconBrightness: Brightness.dark, + )), ), unknownRoute: AppPages.notFoundRoute, initialRoute: AppPages.Initial, @@ -70,10 +77,12 @@ class MyApp extends StatelessWidget { footerTriggerDistance: 150, child: Obx(() { // todo 有没有更好的解决方案 - return ConfigService.to.isGrayFilter.isTrue ? ColorFiltered( - colorFilter: ColorFilter.mode(Colors.grey, BlendMode.color), - child: app, - ) : app; + return ConfigService.to.isGrayFilter.isTrue + ? ColorFiltered( + colorFilter: ColorFilter.mode(Colors.grey, BlendMode.color), + child: app, + ) + : app; }), ); }, diff --git a/lib/utils/update.dart b/lib/utils/update.dart index 8b241a1..491e54c 100644 --- a/lib/utils/update.dart +++ b/lib/utils/update.dart @@ -144,6 +144,9 @@ class AppUpdateUtil { barrierDismissible: false, ); await downloadController.download(fileUrl, fullPath); + + // 释放 + downloadController.dispose(); } // 安装 await InstallPlugin.installApk(fullPath); diff --git a/pubspec.lock b/pubspec.lock index deee1ac..e865df5 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -558,13 +558,21 @@ packages: source: hosted version: "0.27.7" sentry: - dependency: "direct main" + dependency: transitive description: name: sentry - sha256: "377edcc3d7910745849b1621dcec7d34fc27b6c03e9e9009499dc2968ce19cd7" + sha256: "8f4f1d3ef3ca1801aa3138392bbf0851b39eff703008111765b265f76c8f0190" url: "https://pub.flutter-io.cn" source: hosted - version: "5.1.0" + version: "7.8.0" + sentry_flutter: + dependency: "direct main" + description: + name: sentry_flutter + sha256: bbc1048558cf8ae65c1e27b1249357298cfca50e5843ad0367387f5c873b8e42 + url: "https://pub.flutter-io.cn" + source: hosted + version: "7.8.0" share: dependency: "direct main" description: diff --git a/pubspec.yaml b/pubspec.yaml index a67da04..56b93ea 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -88,8 +88,8 @@ dependencies: # permission 权限 permission_handler: ^10.4.3 - # 错误收集 - sentry: ^5.0.0 + # sentry错误收集 + sentry_flutter: ^7.8.0 # webView webview_flutter: ^4.2.2