Home > database >  In the Flutter list view , is there a way to know the number of the list item that the user is tappi
In the Flutter list view , is there a way to know the number of the list item that the user is tappi

Time:12-23

In the Flutter list view, is there a way to know the number of the list item that the user is tapping?.

ListTile( title: Text(snapshot.data[index].quection) );

CodePudding user response:

You just need to use the index of your ListView.builder like below

            ListView.builder(
              itemBuilder: (context, index) => ElevatedButton(
                  onPressed: () {
                    print(index);
                  },
                  child: Text("$index")))
  • Related