removeFromCart method
Remove item from cart
Implementation
Future<Cart> removeFromCart({
required String cartId,
required int itemId,
}) async {
try {
final response = await _client.guestRequest<Map<String, dynamic>>(
'/rest/V1/guest-carts/$cartId/items/$itemId',
options: Options(method: 'DELETE'),
);
if (response.statusCode == 200) {
return Cart.fromJson(response.data!);
} else {
throw Exception(
'Failed to remove item from cart: ${response.statusMessage}',
);
}
} on DioException catch (e) {
throw Exception('Failed to remove item from cart: ${e.message}');
} catch (e) {
throw Exception('Failed to remove item from cart: $e');
}
}