flutter count the number of items created through listviewbuilder and display them

You will pass a list of Products to the ListView.builder, say products. So, the total number of items will be –


Your code will be –

class WishList extends StatefulWidget {
  _WishListState createState() => _WishListState();

class _WishListState extends State<WishList> {

  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.grey[200],
      body: Column(
        children: <Widget> [
            child: Column(
              children: [
                Text('My Wishlist',),
                SizedBox(height: 20),
                Text('You have ${products.length} Items'), // <--------------

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top