fetchStoreCategory method

void fetchStoreCategory(
  1. BuildContext context
)

Implementation

void fetchStoreCategory(BuildContext context) async {
      storeCategoryList.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/categories',
        method: Method.POST,
        params: request);

    ProductCategoryResponse productCategoryResponse =
        ProductCategoryResponse.fromJson(response);
    if (productCategoryResponse.status == Strings.success) {
      storeCategoryList.addAll( productCategoryResponse.data!);
    } else {
      return Utils.showSnackbar(context, Strings.error,
          response['message'].toString().toTitleCase(), AppColors.red);
    }
  } catch (e) {
    return Utils.showSnackbar(
        context, Strings.error, e.toString().toTitleCase(), AppColors.red);
  } finally {
    isLoading(false);
  }
  update();
}