imsujan276 / shopify_flutter

A flutter package that works as a bridge between your Shopify Store and Flutter Application
https://pub.dev/packages/shopify_flutter
MIT License
27 stars 24 forks source link

SKU is Optional in Shopify, so it Can be Nullable in ProductVariantCheckout #43

Closed asadamatic closed 8 months ago

asadamatic commented 8 months ago

When I try to add a product variant that does not have an sku it throws the following error.

Error

Unhandled Exception: type 'Null' is not a subtype of type 'String' in type cast

Stack Trace

#0      _$$ProductVariantCheckoutImplFromJson (package:shopify_flutter/models/src/checkout/product_variant_checkout/product_variant_checkout.g.dart:15:24)
#1      new _$ProductVariantCheckoutImpl.fromJson (package:shopify_flutter/models/src/checkout/product_variant_checkout/product_variant_checkout.freezed.dart:340:7)
#2      _$ProductVariantCheckoutFromJson (package:shopify_flutter/models/src/checkout/product_variant_checkout/product_variant_checkout.freezed.dart:19:34)
#3      new ProductVariantCheckout.fromJson (package:shopify_flutter/models/src/checkout/product_variant_checkout/product_variant_checkout.dart:31:7)
#4      LineItem.fromGraphJson (package:shopify_flutter/models/src/checkout/line_item/line_item.dart:29:36)
#5      JsonHelper.lineItems.<anonymous closure> (package:shopify_flutter/models/json_helper.dart:19:30)
#6      MappedListIterable.elementAt (dart:_i<…>

It points to ProductVariantCheckoutImplFromJson where SKU is expected to be available.

asadamatic commented 8 months ago

Once I get this error, adding any item to the same checkout does not work, and I have to create another checkout.

imsujan276 commented 8 months ago

It has been fixed and available in v1.5.7

asadamatic commented 8 months ago

@imsujan276 The SKU is now nullable is the ProductVariant, but it's still required ProductVariantCheckout.

imsujan276 commented 8 months ago

Thank you for bringing it out.

It has been fixed in v1.5.8

asadamatic commented 8 months ago

Thanks a lot @imsujan276