getSkuDetails method Null safety

  1. @override
Future<ProductDetailsModel> getSkuDetails(
  1. {required String productCode,
  2. required int colorId,
  3. required int sizeId,
  4. required String switchType,
  5. int? customerId}
)
override

It's used when changing the product color or product size.

SwitchType : SwitchColor, SwitchSize

Implementation

@override
Future<ProductDetailsModel> getSkuDetails(
    {required String productCode,
    required int colorId,
    required int sizeId,
    required String switchType,
    int? customerId}) async {
  final response = await postData(path: 'sku/$productCode', queryParameters: {
    'CustomerId': customerId,
    'colorID': colorId,
    'SizeID': sizeId,
    'SwitchType': switchType
  });
  final result = ApiReturnResult.fromJSON(response.data);
  if (result.code == 200) {
    return ProductDetailsModel.fromJson(result.data);
  } else {
    throw ExceptionApi(code: result.code, message: result.error?.first);
  }
}