Update
Logging data Try-catch function
This commit is contained in:
@@ -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());
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user