Logging data
Try-catch function
This commit is contained in:
anhtunz
2025-06-17 16:43:45 +07:00
parent 22fef0e0a8
commit 2d53f2cdd3
41 changed files with 1591 additions and 1299 deletions

View File

@@ -1,8 +1,8 @@
// ignore_for_file: use_build_context_synchronously
import 'dart:convert';
import 'package:dropdown_button2/dropdown_button2.dart';
import 'package:flutter/material.dart';
import '../../../product/shared/shared_snack_bar.dart';
import '../../../bloc/device_notification_settings_bloc.dart';
import 'device_notification_settings_model.dart';
@@ -111,15 +111,12 @@ class _DeviceNotificationSettingsScreenState
}
void getNotificationSetting() async {
try {
await apiServices.execute(context, () async {
deviceNotifications =
await apiServices.getAllSettingsNotificationOfDevices();
deviceNotificationSettingsBloc.sinkListNotifications
.add(deviceNotifications);
} catch (e) {
if (!mounted) return;
showErrorTopSnackBarCustom(context, e.toString());
}
});
}
Widget listNotificationSetting(
@@ -293,13 +290,14 @@ class _DeviceNotificationSettingsScreenState
void updateDeviceNotification(String thingID, Map<String, int> notifiSettings,
bool isDataChange) async {
try {
await apiServices.execute(context, () async {
int statusCode = await apiServices.updateDeviceNotificationSettings(
thingID, notifiSettings);
if (statusCode == 200) {
showNoIconTopSnackBar(
context,
appLocalization(context).notification_update_device_settings_success,
appLocalization(context)
.notification_update_device_settings_success,
Colors.green,
Colors.white);
} else {
@@ -311,11 +309,6 @@ class _DeviceNotificationSettingsScreenState
}
isDataChange = false;
deviceNotificationSettingsBloc.sinkIsDataChange.add(isDataChange);
} catch (e) {
if (!context.mounted) return;
showErrorTopSnackBarCustom(
context, e.toString());
}
});
}
}