Grid Screen

 import 'package:flutter/material.dart';


class GridScreen extends StatefulWidget {
const GridScreen({super.key});

@override
State<GridScreen> createState() => _GridScreenState();
}

class _GridScreenState extends State<GridScreen> {
final List<Choice> choices = [
const Choice(title: 'Home', icon: Icons.home),
const Choice(title: 'Contact', icon: Icons.contacts),
const Choice(title: 'Map', icon: Icons.map),
const Choice(title: 'Phone', icon: Icons.phone),
const Choice(title: 'Camera', icon: Icons.camera_alt),
const Choice(title: 'Setting', icon: Icons.settings),
const Choice(title: 'Album', icon: Icons.photo_album),
const Choice(title: 'WiFi', icon: Icons.wifi),
];

@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
body: GridView.count(
crossAxisCount: 3,
crossAxisSpacing: 4.0,
mainAxisSpacing: 8.0,
children: List.generate(choices.length, (index) {
Choice choice = choices[index];
return Center(
child: Card(
color: Colors.orange,
child: Center(
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Expanded(child: Icon(choice.icon, size: 50.0),),
AppText(fontSize: 10.0, text: choice.title)
],
),
),
),
);
}),
),
),
);
}
}

class Choice {
const Choice({required this.title, required this.icon});

final String title;
final IconData icon;
}

class AppText extends StatelessWidget {
AppText({required this.fontSize, required this.text, super.key});

String text;
double fontSize;

@override
Widget build(BuildContext context) {
return Text(text);
}
}

Comments

Popular posts from this blog

Second GET API Calling with Bloc simple Example in Flutter

Stack Container Scrollable Card widget UI with Custom Widget

Pagination with Bloc Pattern in Flutter