import 'package:flutter/material.dart';
class SimpleGridScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('Simple Grid Screen')),
body: GridView.builder(
padding: const EdgeInsets.all(12),
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 3,
crossAxisSpacing: 12,
mainAxisSpacing: 12,
childAspectRatio: 1,
),
itemCount: 9,
itemBuilder: (context, index) {
return Container(
decoration: BoxDecoration(
color: Colors.blue[(index + 1) * 100],
borderRadius: BorderRadius.circular(8),
),
child: Center(
child: Text(
'${index + 1}',
style: const TextStyle(
fontSize: 24,
color: Colors.white,
fontWeight: FontWeight.bold,
),
),
),
);
},
),
);
}
}
void main() {
runApp(MaterialApp(home: SimpleGridScreen()));
}We use GridView.builder to create a grid with 9 items dynamically. The gridDelegate sets 3 columns with spacing between items. Each item is a square container with a blue shade background and a white number centered. This approach is efficient for large or dynamic lists because it builds items on demand.