Horizontally Center Last Odd Item of Gridview or ListView
I tried staggeredGridView but it doesnt have alignment.
2
here how i solved
SizedBox( height: h * 0.4, child: StaggeredGridView.countBuilder( crossAxisCount: 3, itemCount: 7, itemBuilder: (BuildContext context, int index) => Container( child: Center( child: Container( height: w / 4, width: w / 4, decoration: const BoxDecoration( color: Colors.green, borderRadius: BorderRadius.all(Radius.circular(10)), ), child: Center( child: Text( index == 6 ? "C" : "$index", style: const TextStyle( fontSize: 20, fontWeight: FontWeight.bold), ), ), ), )), staggeredTileBuilder: (int index) => StaggeredTile.count(index == 6 ? 3 : 1, 1), ), ),
Please try the below code :
Click here to cancel reply.
2
Answers
here how i solved
Please try the below code :