'Unable to display items in Listview. Error type 'string' is not a subtype of type 'int' of 'index'

enter image description here

The bottom of the screen reads, A RenderFlex overflowed by 99369 pixels

I am having some problems displaying the list view, I have made integer values to string, what am i doing wrong?

      body: Column(
    children: <Widget>[
      StreamBuilder(
        stream: database.onValue,
        builder: (context, AsyncSnapshot<Event> snapshot) {
          if (snapshot.hasData && !snapshot.hasError &&
              snapshot.data!.snapshot.value != null) {
            print("Error on the way");
            lists.clear();
            DataSnapshot dataValues = snapshot.data!.snapshot;
            Map<dynamic, dynamic> values = dataValues.value;
            values.forEach((key, values) {
              lists.add(values);
            });
            return  ListView.builder(
              shrinkWrap: true,
              itemCount: lists.length,
              itemBuilder: (BuildContext context,int index) {
                return Card(
                  child: Column(
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: <Widget>[
                      Text("Item: " + lists[index]["Item"]),
                      Text("Expiry Date: " + lists[index]["Expiry Date"]),
                      Text("Quantity: " + lists[index]["Quantity"].toString()),
                    ],
                  ),
                );
              },
            );
          }
          return Container(child: Text("Add Items"));
        },
      ),
      ElevatedButton(
        child: const Text('Add Items'),
        onPressed: () {
          Navigator.push(
            context,
            MaterialPageRoute(builder: (context) => const AddItem()),
          );
        },
      ),
    ],

  ),

Any help will be greatly appreciated!



Solution 1:[1]

It means that there might be some list inside a list for that you have to use two index value for example :

list[index][0]['Item']

i dont know where it will be it can be found easily by looking at its response ,it can be for item,expiry or quantity check for that in the response .

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 Dharman