Update
Logging data Try-catch function
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
// ignore_for_file: use_build_context_synchronously
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../product/shared/shared_snack_bar.dart';
|
||||
import '../../../product/constant/icon/icon_constants.dart';
|
||||
import '../../../product/services/api_services.dart';
|
||||
@@ -8,7 +9,6 @@ import '../../../bloc/settings_bloc.dart';
|
||||
import '../../../product/shared/shared_input_decoration.dart';
|
||||
import '../../../product/extension/context_extension.dart';
|
||||
import '../../../product/services/language_services.dart';
|
||||
|
||||
import 'profile_model.dart';
|
||||
|
||||
changeUserInfomation(
|
||||
@@ -38,7 +38,7 @@ changeUserInfomation(
|
||||
? IconButton(
|
||||
onPressed: () async {
|
||||
if (formKey.currentState!.validate()) {
|
||||
try {
|
||||
await apiServices.execute(context,() async {
|
||||
formKey.currentState!.save();
|
||||
String latitude = user.latitude ?? "";
|
||||
String longitude = user.longitude ?? "";
|
||||
@@ -51,7 +51,7 @@ changeUserInfomation(
|
||||
"longitude": longitude
|
||||
};
|
||||
int statusCode =
|
||||
await apiServices.updateUserProfile(body);
|
||||
await apiServices.updateUserProfile(body);
|
||||
if (statusCode == 200) {
|
||||
showNoIconTopSnackBar(
|
||||
modalBottomSheetContext,
|
||||
@@ -69,11 +69,42 @@ changeUserInfomation(
|
||||
}
|
||||
settingsBloc.getUserProfile(context);
|
||||
Navigator.pop(modalBottomSheetContext);
|
||||
} catch (e) {
|
||||
if (!context.mounted) return;
|
||||
showErrorTopSnackBarCustom(
|
||||
context, e.toString());
|
||||
}
|
||||
});
|
||||
// try {
|
||||
// formKey.currentState!.save();
|
||||
// String latitude = user.latitude ?? "";
|
||||
// String longitude = user.longitude ?? "";
|
||||
// Map<String, dynamic> body = {
|
||||
// "name": username,
|
||||
// "email": email,
|
||||
// "phone": tel,
|
||||
// "address": address,
|
||||
// "latitude": latitude,
|
||||
// "longitude": longitude
|
||||
// };
|
||||
// int statusCode =
|
||||
// await apiServices.updateUserProfile(body);
|
||||
// if (statusCode == 200) {
|
||||
// showNoIconTopSnackBar(
|
||||
// modalBottomSheetContext,
|
||||
// appLocalization(context)
|
||||
// .notification_update_profile_success,
|
||||
// Colors.green,
|
||||
// Colors.white);
|
||||
// } else {
|
||||
// showNoIconTopSnackBar(
|
||||
// modalBottomSheetContext,
|
||||
// appLocalization(context)
|
||||
// .notification_update_profile_failed,
|
||||
// Colors.redAccent,
|
||||
// Colors.white);
|
||||
// }
|
||||
// settingsBloc.getUserProfile(context);
|
||||
// Navigator.pop(modalBottomSheetContext);
|
||||
// } catch (e) {
|
||||
// if (!context.mounted) return;
|
||||
// showErrorTopSnackBarCustom(context, e.toString());
|
||||
// }
|
||||
}
|
||||
},
|
||||
icon:
|
||||
@@ -212,7 +243,7 @@ changeUserInfomation(
|
||||
child: TextButton(
|
||||
onPressed: () async {
|
||||
if (formKey.currentState!.validate()) {
|
||||
try {
|
||||
await apiServices.execute(context,() async {
|
||||
formKey.currentState!.save();
|
||||
String latitude = user.latitude ?? "";
|
||||
String longitude = user.longitude ?? "";
|
||||
@@ -224,8 +255,8 @@ changeUserInfomation(
|
||||
"latitude": latitude,
|
||||
"longitude": longitude
|
||||
};
|
||||
int statusCode =
|
||||
await apiServices.updateUserProfile(body);
|
||||
int statusCode = await apiServices
|
||||
.updateUserProfile(body);
|
||||
if (statusCode == 200) {
|
||||
showNoIconTopSnackBar(
|
||||
modalBottomSheetContext,
|
||||
@@ -243,11 +274,7 @@ changeUserInfomation(
|
||||
}
|
||||
settingsBloc.getUserProfile(context);
|
||||
Navigator.pop(modalBottomSheetContext);
|
||||
} catch (e) {
|
||||
if (!context.mounted) return;
|
||||
showErrorTopSnackBarCustom(
|
||||
context, e.toString());
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
style: const ButtonStyle(
|
||||
@@ -296,15 +323,15 @@ changeUserPassword(BuildContext context, SettingsBloc settingsBloc) {
|
||||
isChangeSnapshot.data ?? isChange
|
||||
? IconButton(
|
||||
onPressed: () async {
|
||||
try {
|
||||
if (formKey.currentState!.validate()) {
|
||||
if (formKey.currentState!.validate()) {
|
||||
await apiServices.execute(context,() async {
|
||||
formKey.currentState!.save();
|
||||
Map<String, dynamic> body = {
|
||||
"password_old": oldPass,
|
||||
"password_new": newPass,
|
||||
};
|
||||
int statusCode =
|
||||
await apiServices.updateUserPassword(body);
|
||||
await apiServices.updateUserPassword(body);
|
||||
if (statusCode == 200) {
|
||||
showNoIconTopSnackBar(
|
||||
modalBottomSheetContext,
|
||||
@@ -321,11 +348,7 @@ changeUserPassword(BuildContext context, SettingsBloc settingsBloc) {
|
||||
Colors.white);
|
||||
}
|
||||
Navigator.pop(modalBottomSheetContext);
|
||||
}
|
||||
} catch (e) {
|
||||
if (!context.mounted) return;
|
||||
showErrorTopSnackBarCustom(
|
||||
context, e.toString());
|
||||
});
|
||||
}
|
||||
},
|
||||
icon:
|
||||
@@ -410,15 +433,15 @@ changeUserPassword(BuildContext context, SettingsBloc settingsBloc) {
|
||||
? Center(
|
||||
child: TextButton(
|
||||
onPressed: () async {
|
||||
try {
|
||||
await apiServices.execute(context,() async {
|
||||
if (formKey.currentState!.validate()) {
|
||||
formKey.currentState!.save();
|
||||
Map<String, dynamic> body = {
|
||||
"password_old": oldPass,
|
||||
"password_new": newPass,
|
||||
};
|
||||
int statusCode =
|
||||
await apiServices.updateUserPassword(body);
|
||||
int statusCode = await apiServices
|
||||
.updateUserPassword(body);
|
||||
if (statusCode == 200) {
|
||||
showNoIconTopSnackBar(
|
||||
modalBottomSheetContext,
|
||||
@@ -436,11 +459,38 @@ changeUserPassword(BuildContext context, SettingsBloc settingsBloc) {
|
||||
}
|
||||
Navigator.pop(modalBottomSheetContext);
|
||||
}
|
||||
} catch (e) {
|
||||
if (!context.mounted) return;
|
||||
showErrorTopSnackBarCustom(
|
||||
context, e.toString());
|
||||
}
|
||||
});
|
||||
// try {
|
||||
// if (formKey.currentState!.validate()) {
|
||||
// formKey.currentState!.save();
|
||||
// Map<String, dynamic> body = {
|
||||
// "password_old": oldPass,
|
||||
// "password_new": newPass,
|
||||
// };
|
||||
// int statusCode = await apiServices
|
||||
// .updateUserPassword(body);
|
||||
// if (statusCode == 200) {
|
||||
// showNoIconTopSnackBar(
|
||||
// modalBottomSheetContext,
|
||||
// appLocalization(context)
|
||||
// .notification_update_password_success,
|
||||
// Colors.green,
|
||||
// Colors.white);
|
||||
// } else {
|
||||
// showNoIconTopSnackBar(
|
||||
// modalBottomSheetContext,
|
||||
// appLocalization(context)
|
||||
// .notification_update_password_failed,
|
||||
// Colors.redAccent,
|
||||
// Colors.white);
|
||||
// }
|
||||
// Navigator.pop(modalBottomSheetContext);
|
||||
// }
|
||||
// } catch (e) {
|
||||
// if (!context.mounted) return;
|
||||
// showErrorTopSnackBarCustom(
|
||||
// context, e.toString());
|
||||
// }
|
||||
},
|
||||
style: const ButtonStyle(
|
||||
backgroundColor:
|
||||
|
||||
Reference in New Issue
Block a user