'How to compare items in the gridview in flutter?

I have been trying to but can't figure quite how to create a gridview displaying items from a online strore and to be able to compare between two items that have been selected from a checkbox. Does anyone how to do this?



Solution 1:[1]

You could overwrite the equality operator and hashcode for your GridView Item class.

Then you can just compare those items via a typical == operator. Remember, always override hashCode property when overriding the == operator.

There's also a common library that is used to simplify this called Equatable. The usage is pretty straight forward if you check the examples on pub.dev

Solution 2:[2]

I don't have access to the items from your online store, instead I used freely available data about Harry Potter Characters.

I used a gridview to display the data items. Once two items are selected a bottomsheet pops up showing the comparison.

Here is a gif of the working app, code can be found here.

I used flutter_bloc to implement the bloc pattern to this app. All the logic is managed in CharacterBloc which responds to three events

  1. Fetching data
  2. Selecting characters
  3. De-selecting characters

Solution 3:[3]

In your serve.json file change initialPage to either Sharepoint site - for example "https://XXX.sharepoint.com/_layouts/15/workbench.aspx" - this will open Sharepoint workbench or in browser after running gulp serve go to the site "https://localhost:4321/temp/workbench.html" - this will open local workbench

The error is that you are trying opening workbench at site - https://enter-your-SharePoint-site/_layouts/workbench.aspx which clearly does not exists.

Please reffer to: MS doc

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 George Spanos
Solution 2 Vipin Kumar Kashyap
Solution 3