From b9f355cdbf5eaf2dc66564679a89854ac45b54ad Mon Sep 17 00:00:00 2001 From: jantunesmessias Date: Mon, 17 Feb 2025 09:23:01 -0300 Subject: [PATCH 1/3] firebase crashlytics fix --- lib/initialization.dart | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/lib/initialization.dart b/lib/initialization.dart index 1d50273e..c3d32845 100644 --- a/lib/initialization.dart +++ b/lib/initialization.dart @@ -53,26 +53,29 @@ Future _initializeSystemSettings() async { final crashlyticsInstance = FirebaseCrashlytics.instance; await SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]); + if (kDebugMode) { - //kDebugMode print('Debug mode'); + await crashlyticsInstance.setCrashlyticsCollectionEnabled(false); } else { print('Release mode'); - bool unsentReports = - await FirebaseCrashlytics.instance.checkForUnsentReports(); - if (unsentReports) { - // Existem relatórios não enviados - await crashlyticsInstance.sendUnsentReports(); - print('Existem relatórios de falhas não enviados.'); - } else { - // Não existem relatórios não enviados - print('Todos os relatórios de falhas foram enviados.'); - } await crashlyticsInstance.setCrashlyticsCollectionEnabled(true); - // if (crashlyticsInstance.isCrashlyticsCollectionEnabled) { - FlutterError.onError = await crashlyticsInstance.recordFlutterError; + + // Verifica e envia relatórios não enviados de forma assíncrona + crashlyticsInstance.checkForUnsentReports().then((unsentReports) { + if (unsentReports) { + crashlyticsInstance.sendUnsentReports(); + print('Existem relatórios de falhas não enviados.'); + } else { + print('Todos os relatórios de falhas foram enviados.'); + } + }).catchError((error) { + print('Erro ao verificar ou enviar relatórios não enviados: $error'); + }); + + // Configura o tratamento de erros não capturados + FlutterError.onError = crashlyticsInstance.recordFlutterError; print('Crashlytics enabled'); - // } } } From 3a9772558fa1e9e0421315567f24842b70622919 Mon Sep 17 00:00:00 2001 From: jantunesmessias Date: Mon, 17 Feb 2025 12:08:27 -0300 Subject: [PATCH 2/3] FIX --- .../vehicle_history_screen.dart | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/pages/vehicles_on_the_property/vehicle_history_screen.dart b/lib/pages/vehicles_on_the_property/vehicle_history_screen.dart index 1e90cc84..ddbf6271 100644 --- a/lib/pages/vehicles_on_the_property/vehicle_history_screen.dart +++ b/lib/pages/vehicles_on_the_property/vehicle_history_screen.dart @@ -11,7 +11,7 @@ class VehicleHistoryScreen extends StatefulWidget { class _VehicleHistoryScreenState extends State with Pageable { final apiCall = PhpGroup.getVehiclesByProperty; - int count = 0; + int totalOwnerVehicles = 0; final PagingController _pagingController = PagingController(firstPageKey: 1); bool _isSnackble = true; @@ -28,7 +28,7 @@ class _VehicleHistoryScreenState extends State (newItems.jsonBody['vehicles'] as List?) ?? []; safeSetState(() { - count = newItems.jsonBody['total_rows'] ?? 0; + totalOwnerVehicles = newItems.jsonBody['total_owner_vehicles'] ?? 0; }); return (vehicles.isNotEmpty, vehicles); @@ -96,6 +96,12 @@ class _VehicleHistoryScreenState extends State Widget _buildHeader(BuildContext context) { final bodyFontSize = LimitedFontSizeUtil.getBodyFontSize(context); + final headerTitle = FFLocalizations.of(context).getVariableText( + ptText: "Meus Veículos: ", + enText: "My Vehicles: ", + ); + final totalRegisteredVehicles = widget.model.amountRegister; + return SizedBox( height: 30, child: Center( @@ -103,7 +109,7 @@ class _VehicleHistoryScreenState extends State (widget.model.amountRegister == '0' || widget.model.amountRegister == null) ? '' - : "${FFLocalizations.of(context).getVariableText(ptText: "Quantidade de Veículos: ", enText: "Amount of Vehicles: ")}${widget.model.amountRegister}/$count", + : "$headerTitle $totalOwnerVehicles/$totalRegisteredVehicles", textAlign: TextAlign.right, style: TextStyle( fontFamily: 'Nunito', From e08a049000daa2f56468c8066ae10c2c15a81a93 Mon Sep 17 00:00:00 2001 From: jantunesmessias Date: Mon, 17 Feb 2025 14:17:08 -0300 Subject: [PATCH 3/3] comment crashlytics 'fix' --- lib/initialization.dart | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/initialization.dart b/lib/initialization.dart index c3d32845..939143ca 100644 --- a/lib/initialization.dart +++ b/lib/initialization.dart @@ -56,22 +56,22 @@ Future _initializeSystemSettings() async { if (kDebugMode) { print('Debug mode'); - await crashlyticsInstance.setCrashlyticsCollectionEnabled(false); + // await crashlyticsInstance.setCrashlyticsCollectionEnabled(false); } else { print('Release mode'); - await crashlyticsInstance.setCrashlyticsCollectionEnabled(true); + // await crashlyticsInstance.setCrashlyticsCollectionEnabled(true); // Verifica e envia relatórios não enviados de forma assíncrona - crashlyticsInstance.checkForUnsentReports().then((unsentReports) { - if (unsentReports) { - crashlyticsInstance.sendUnsentReports(); - print('Existem relatórios de falhas não enviados.'); - } else { - print('Todos os relatórios de falhas foram enviados.'); - } - }).catchError((error) { - print('Erro ao verificar ou enviar relatórios não enviados: $error'); - }); + // crashlyticsInstance.checkForUnsentReports().then((unsentReports) { + // if (unsentReports) { + // crashlyticsInstance.sendUnsentReports(); + // print('Existem relatórios de falhas não enviados.'); + // } else { + // print('Todos os relatórios de falhas foram enviados.'); + // } + // }).catchError((error) { + // print('Erro ao verificar ou enviar relatórios não enviados: $error'); + // }); // Configura o tratamento de erros não capturados FlutterError.onError = crashlyticsInstance.recordFlutterError;