0
votes

I am simply checking my ids array in other array. In one array i have bunch of ids in array and i am fltering second array where id exist.

My code

  Future<List> dosomestuff() async {
    var map = globalCategoryProduct.globalCategoryProductArray;
    print(map);
    print(WishList.wishlistArray);
    if (map.length > 1) {
      //print('show kr ');
      var data = map;

      data.forEach(
        (category) {
          print(category);
          final filteredItemsToAdd = category
              .where((item) => WishList.wishlistArray.contains(item['ItemID']));
          print(filteredItemsToAdd);
        },
      );
      if (items['Items'].length >= 1) {
        setState(() {
          show = true;
        });
      }
    }
  }

And i have some helper of global array like this

class globalCategoryProduct {
  static var globalCategoryProductArray = [];
}


class WishList {
  static var wishlistArray = [];
}

I am adding arrays in these global array and then fetch on other screen.

But dont know why its showing error of Class '_InternalLinkedHashMap<String, dynamic>' has no instance method 
1

1 Answers

0
votes

There is an issue with your globalist. You need to change it or you can use this shortcut

  data.forEach(
    (category) {
      if(WishList.wishlistArray.contains(category['ItemID'])){
        print(category);
        //you can do here what ever you want
      }
    },
  );

It will just check in the wishlist if the item match so it will print you can add in some array or whatever you want.