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 –

products.length

Your code will be –

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

class _WishListState extends State<WishList> {

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.grey[200],
      body: Column(
        children: <Widget> [
          Container(
            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