fetchSupportCategory method
Implementation
void fetchSupportCategory(BuildContext context) async {
productTypeList.clear();
try {
isLoading(true);
var request = {
'merchant_id': Storage.getValue(Constants.merchantID),
'api_key': await Constants.apiKey()
};
var response = await DioClient().request(
context: context,
api: '/merchant/support/get-support-message-categories',
method: Method.POST,
params: request);
ProductCategoryResponse productCategoryResponse =
ProductCategoryResponse.fromJson(response);
if (productCategoryResponse.status == Strings.success) {
productTypeList.addAll(productCategoryResponse.data!);
productType = productTypeList.first;
} else {
isError(true);
errorMessage.value = response['message'].toString().toTitleCase();
return Utils.showSnackbar(context, Strings.error,
response['message'].toString().toTitleCase(), AppColors.red);
}
} catch (e) {
isError(true);
errorMessage.value = e.toString().toTitleCase();
return Utils.showSnackbar(
context, Strings.error, e.toString().toTitleCase(), AppColors.red);
} finally {
isLoading(false);
}
update();
}