Table Widget in Flutter

 import "package:flutter/material.dart";

import "package:sdreatech_learning_widget/All_widgets_Ui/customWidget.dart";

void main() {
runApp(const MyApp());
}

class MyApp extends StatelessWidget {
const MyApp({super.key});

@override
Widget build(BuildContext context) {
return MaterialApp(
title: "Table Widget",
debugShowCheckedModeBanner: false,
theme: ThemeData(
appBarTheme: const AppBarTheme(
backgroundColor: Colors.grey,
centerTitle: true,
),
),
home: const TableWidgetPractice(),
);
}
}

class TableWidgetPractice extends StatelessWidget {
const TableWidgetPractice({super.key});

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: UiHelper.customAppBar("Table Widget"),
body: Center(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Table(
border: TableBorder.all(color: Colors.black),
children: [
const TableRow(
decoration: BoxDecoration(
color: Colors.grey,
),
children: [
TableCell(
verticalAlignment: TableCellVerticalAlignment.middle,
child: Padding(
padding: EdgeInsets.all(8.0),
child: Text(
"Table 1",
style: TextStyle(
fontWeight: FontWeight.bold, color: Colors.white),
),
),
),
TableCell(
verticalAlignment: TableCellVerticalAlignment.middle,
child: Padding(
padding: EdgeInsets.all(8.0),
child: Text(
"Table 2",
style: TextStyle(
fontWeight: FontWeight.bold, color: Colors.white),
),
),
),
TableCell(
verticalAlignment: TableCellVerticalAlignment.middle,
child: Padding(
padding: EdgeInsets.all(8.0),
child: Text(
"Table 3",
style: TextStyle(
fontWeight: FontWeight.bold, color: Colors.white),
),
),
),
],
),
...List.generate(
20,
(index) {
return const TableRow(
children: [
TableCell(
verticalAlignment: TableCellVerticalAlignment.middle,
child: Padding(
padding: EdgeInsets.all(8.0),
child: Text("Cell 1"),
),
),
TableCell(
verticalAlignment: TableCellVerticalAlignment.middle,
child: Padding(
padding: EdgeInsets.all(8.0),
child: Text("Cell 2"),
),
),
TableCell(
verticalAlignment: TableCellVerticalAlignment.middle,
child: Padding(
padding: EdgeInsets.all(8.0),
child: Text("Cell 3"),
),
),
],
);
},
),
],
),
),
),
);
}
}


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