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
26 stars 27 forks source link

ShopifyCart.instance addLineItemsToCart throws an exception #95

Closed lachlanh closed 1 month ago

lachlanh commented 1 month ago

I am getting an error adding line items to a cart. The error is :

addLineItemToCart Error: type 'List<dynamic>' is not a subtype of type 'List<CartDiscountAllocation?>?' stack: #0      new Line.fromGraphJson (package:shopify_flutter/models/src/cart/lines/line/line.dart:44:11)
I/flutter ( 8441): #1      JsonHelper.lines.<anonymous closure> (package:shopify_flutter/models/json_helper.dart:20:52)
I/flutter ( 8441): #2      MappedListIterable.elementAt (dart:_internal/iterable.dart:425:31)
I/flutter ( 8441): #3      ListIterator.moveNext (dart:_internal/iterable.dart:354:26)
I/flutter ( 8441): #4      new _GrowableList._ofEfficientLengthIterable (dart:core-patch/growable_array.dart:189:27)
I/flutter ( 8441): #5      new _GrowableList.of (dart:core-patch/growable_array.dart:150:28)
I/flutter ( 8441): #6      new List.of (dart:core-patch/array_patch.dart:39:18)
I/flutter ( 8441): #7      ListIterable.toList (dart:_internal/iterable.dart:224:7)
I/flutter ( 8441): #8      JsonHelper.lines (package:shopify_flutter/models/json_helper.dart:20:70)
I/flutter ( 8441): #9      _$$CartImplFromJson (package:shopify_flutter/models/src/cart/cart.g.dart:33:25)
I/flutter ( 8441): #10     new _$CartImpl.fromJson (package:shopify_flutter/models/src/cart/cart.freezed.dart:293:7)
I/flutter ( 8441): #11
I/flutter ( 8441): #0      _CartTabState.addLineItemToCart (package:example/screens/cart_tab.dart:113:46)

This stack trace is from the example app included with the sdk (I added the stack trace on error), I tried my own implementation and got a similar error. I have tried going back to version 2.0.0 but see a similar error there. Not sure if this could be related to #94 ? Thanks for putting this package together, any insight is much appreciated.

EDIT: I am able to add line items to the cart using curl and a graphql query so I think the shopify storefront config I am using is ok.

FrancoTerranovaJob commented 1 month ago

same problem here on latest version

imsujan276 commented 1 month ago

This issue has been resolved in v2.2.5