How to Change width of element inside ListView? How to Change width of element inside ListView? flutter flutter

How to Change width of element inside ListView?


Try wrap it in Row like this:

  body: ListView.builder(    itemCount: 10,    itemBuilder: (ctx, index) {      return Row(       children:[         SizedBox(          width: 10,          height: 10,          child: Card(           color: btnColor,           child: Text(            "Helo",            // loremIpsum,            style: TextStyle(color: Colors.black.withOpacity(0.6)),          ),        ),      )]     );    },  ),


I fixed my issue from this link:

body: ListView.builder(        itemCount: 10,        itemBuilder: (ctx, index) {          return Row(            children: [              Container(height: 50, width: 50, color: Colors.black),            ],          );        },      ),

Just use Row inside the ListView


Widget build(BuildContext context) {var screenWidth = MediaQuery.of(context).size.width;

return Scaffold(  body: SingleChildScrollView(    child: Container(      width: screenWidth / 2, //Takes half of the screen size      child: ListView.builder(        physics: NeverScrollableScrollPhysics(),        itemCount: 10,        itemBuilder: (ctx, index) {          return Text(index.toString());        },      ),    ),  ),);

}