Update
Logging data Try-catch function
This commit is contained in:
@@ -1,8 +1,7 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:sfm_app/product/shared/shared_snack_bar.dart';
|
||||
import '../../product/extension/context_extension.dart';
|
||||
|
||||
import '../../product/services/language_services.dart';
|
||||
import '../../bloc/bell_bloc.dart';
|
||||
import '../../product/base/bloc/base_bloc.dart';
|
||||
@@ -77,7 +76,8 @@ class _BellScreenState extends State<BellScreen> {
|
||||
if (index < bellSnapshot.data!.length) {
|
||||
return GestureDetector(
|
||||
onTap: () async {
|
||||
readNotification(bellSnapshot.data![index].id!);
|
||||
readNotification(
|
||||
bellSnapshot.data![index].id!);
|
||||
},
|
||||
child: Column(
|
||||
children: [
|
||||
@@ -163,24 +163,18 @@ class _BellScreenState extends State<BellScreen> {
|
||||
getBellNotification(offset);
|
||||
}
|
||||
|
||||
void readNotification(String id) async{
|
||||
try {
|
||||
void readNotification(String id) async {
|
||||
await apiServices.execute(context, () async {
|
||||
List<String> read = [];
|
||||
read.add(id);
|
||||
await apiServices
|
||||
.updateStatusOfNotification(read);
|
||||
await apiServices.updateStatusOfNotification(read);
|
||||
read.clear();
|
||||
} catch (e) {
|
||||
if (mounted){
|
||||
showErrorTopSnackBarCustom(
|
||||
context, e.toString());
|
||||
}
|
||||
}
|
||||
});
|
||||
refresh();
|
||||
}
|
||||
|
||||
Future<void> getBellNotification(int offset) async {
|
||||
try {
|
||||
apiServices.execute(context, () async {
|
||||
bell = await apiServices.getBellNotifications(
|
||||
offset.toString(), (offset + 20).toString());
|
||||
if (bell.items!.isEmpty) {
|
||||
@@ -193,10 +187,7 @@ class _BellScreenState extends State<BellScreen> {
|
||||
}
|
||||
bellBloc.bellItems.add(items);
|
||||
check = false;
|
||||
} catch (e) {
|
||||
if (!mounted) return;
|
||||
showErrorTopSnackBarCustom(context, e.toString());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
String timeAgo(BuildContext context, DateTime dateTime) {
|
||||
|
||||
Reference in New Issue
Block a user