Table Widget
Project Preview
- Interested in seeing the live demo? Click here to explore.
- Want to view the source code? Visit the project on GitHub.
Code Snippet
import 'package:flutter/material.dart';
class TableWidget extends StatelessWidget {
const TableWidget({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text("Table Widget"),
),
body: Center(
child: SingleChildScrollView(
child: Padding(
padding: const EdgeInsets.all(15.0),
child: Table(
border: TableBorder.all(color: Colors.white30),
defaultVerticalAlignment: TableCellVerticalAlignment.middle,
children: [
const TableRow(
decoration: BoxDecoration(
color: Colors.redAccent,
),
children: [
TableCell(
verticalAlignment: TableCellVerticalAlignment.middle,
child: Padding(
padding: EdgeInsets.all(8.0),
child: Text('Title - 1'),
),
),
TableCell(
verticalAlignment: TableCellVerticalAlignment.middle,
child: Padding(
padding: EdgeInsets.all(8.0),
child: Text('Title - 2'),
),
),
TableCell(
verticalAlignment: TableCellVerticalAlignment.middle,
child: Padding(
padding: EdgeInsets.all(8.0),
child: Text('Title - 3'),
),
),
],
),
...List.generate(
20,
(index) => 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'),
),
),
],
),
)
],
),
),
),
),
);
}
}