Hello everyone I have this error when trying to acces to a product from another route than the main route ( trying from scanner QR. '_InternalLinkedHashMap<String, dynamic>' is not a subtype of type 'String'.
The main route is working fine & this error only happen to variable product.
This is the call of the widget and the first error
Consumer<ProductManagmentModel>(
builder: (_, model, __) {
if (model.product!.type != 'variable') {
return const SizedBox();
}
return VariationWidget(
variations: model.product!.variationProducts ?? [],
productAttributes: model.product!.vendorAdminProductAttributes,
onUpdate: (list) {
model.updateVariations(list);
},
);
},
),
Where does the second error come from in the Variation_Widget.dart at line opts.add(attr.options![i]);
List<ProductVariation> _generateVariations() {
var _variations = <ProductVariation>[];
var options = <List<String>>[];
var slugs = <List<String>>[];
var attrNames = <String>[];
for (var attr in productAttributes) {
if (!(attr.isActive ?? false)) {
continue;
}
if (!(attr.isVariation ?? false)) {
continue;
}
var opts = <String>[];
var sls = <String>[];
for (var i = 0; i < attr.options!.length; i++) {
opts.add(attr.options![i]);
sls.add(attr.optionSlugs[i]);
}
options.add(opts);
slugs.add(sls);
attrNames.add(attr.slug ?? '');
}
final list = combinations(options, slugs, attrNames).map((e) => e.toList()).toList();
for (var item in list) {
if (item.isNotEmpty) {
var variation = ProductVariation()..attributeList = item;
_variations.add(variation);
}
}
return _variations;
}
This is where the data are parsed from API (product.dart)
if (parsedJson['attributesData'] != null) {
try {
parsedJson['attributesData'].forEach((element) =>
vendorAdminProductAttributes
.add(ProductAttribute.fromJson(element)..isActive = true));
} catch (e) {
printLog(e);
}
}
if (parsedJson['variation_products'] != null) {
for (var item in parsedJson['variation_products']) {
vendorAdminVariations.add(VendorAdminVariation.fromJson(item));
}
}
Thank you for any help i'am block with the scanner QR since 2 weeks