79802441

Date: 2025-10-28 05:05:16
Score: 0.5
Natty:
Report link

There is a Very Simple way just use centered_grid package :-

  1. install By typing flutter pub add centered_grid and copy paste this example

    import 'package:flutter/material.dart';
    import 'package:centered_grid/centered_grid.dart';
    
    class ExamplePage extends StatelessWidget {
      final List<String> imageUrls = [
        "https://dummyimage.com/180x150&text=1",
        "https://dummyimage.com/180x150&text=2",
        "https://dummyimage.com/180x150&text=3",
        "https://dummyimage.com/180x150&text=4",
        "https://dummyimage.com/180x150&text=5",
      ];
    
      @override
      Widget build(BuildContext context) {
        return Scaffold(
          appBar: AppBar(title: Text("CustomGrid Example")),
          body: Column(
            children: [
               CenteredGrid(
                itemCount: imageUrls.length,
                crossAxisCount: 3,
                crossAxisSpacing: 12,
                mainAxisSpacing: 8,
                itemBuilder: (context, index) {
                  return Image.network(imageUrls[index]);
                },
              ),
            ],
          ),
        );
      }
    }
    
  2. Output:-

    enter image description here

Reasons:
  • Blacklisted phrase (1): enter image description here
  • Long answer (-1):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: Naresh Gupta