import 'package:flutter/material.dart'; class NotificationCustomScreen extends StatefulWidget { const NotificationCustomScreen({super.key}); @override State createState() => _NotificationCustomScreenState(); } class _NotificationCustomScreenState extends State { List tableDataRows = [ const TableRow( children: [ TableCell( child: Text('Row 1, Column 1'), ), TableCell( child: Text('Row 1, Column 2'), ), ], ), const TableRow( children: [ TableCell( child: Text('Row 2, Column 1'), ), TableCell( child: Text('Row 2, Column 2'), ), ], ), const TableRow( children: [ TableCell( child: Text('Row 3, Column 1'), ), TableCell( child: Text('Row 3, Column 2'), ), ], ), const TableRow( children: [ TableCell( child: Text('Row 4, Column 1'), ), TableCell( child: Text('Row 4, Column 2'), ), ], ), const TableRow( children: [ TableCell( child: Text('Row 5, Column 1'), ), TableCell( child: Text('Row 5, Column 2'), ), ], ), ]; @override Widget build(BuildContext context) { var headers = ["Start date", "End date", "Note", "Created by"]; var list = [ { 'Start date': "06/09/2023", "End date": "11/10/2023", "notification": "Test notifications", "createdby": "Sneha" }, { 'Start date': "06/09/2023", "End date": "11/09/2023", "notification": "Test notifications", "createdby": "Sneha" }, ]; return MaterialApp( home: Scaffold( appBar: AppBar( title: const Text('Notifications'), backgroundColor: const Color.fromARGB(255, 11, 60, 144), ), body: Padding( padding: const EdgeInsets.all(20.0), child: Center( child: Column( children: [ Table( border: TableBorder.all(color: Colors.black), columnWidths: { 0: FixedColumnWidth( MediaQuery.of(context).size.height * 0.30), 1: FixedColumnWidth( MediaQuery.of(context).size.height * 0.30), 2: FixedColumnWidth( MediaQuery.of(context).size.height * 0.30), 3: FixedColumnWidth( MediaQuery.of(context).size.height * 0.30) }, children: [ // for (var item in headers) TableRow(children: [ Padding( padding: const EdgeInsets.all(8.0), child: Center( child: Text( headers[0], style: const TextStyle(fontSize: 18.0), ), ), ), Padding( padding: const EdgeInsets.all(8.0), child: Center( child: Text( headers[1], style: const TextStyle(fontSize: 18.0), ), ), ), Padding( padding: const EdgeInsets.all(8.0), child: Center( child: Text( headers[2], style: const TextStyle(fontSize: 18.0), ), ), ), Padding( padding: const EdgeInsets.all(8.0), child: Center( child: Text( headers[3], style: const TextStyle(fontSize: 18.0), ), ), ), // Text(item[1]), // Text(item[2]), ]) ]), Table( border: TableBorder.all(color: Colors.black), columnWidths: { 0: FixedColumnWidth( MediaQuery.of(context).size.height * 0.30), 1: FixedColumnWidth( MediaQuery.of(context).size.height * 0.30), 2: FixedColumnWidth( MediaQuery.of(context).size.height * 0.30), 3: FixedColumnWidth( MediaQuery.of(context).size.height * 0.30) }, children: [ for (var item in list) TableRow(children: [ Padding( padding: const EdgeInsets.all(8.0), child: Text( item['Start date']!, style: const TextStyle(fontSize: 18.0), ), ), Padding( padding: const EdgeInsets.all(8.0), child: Text( item['End date']!, style: const TextStyle(fontSize: 18.0), ), ), Padding( padding: const EdgeInsets.all(8.0), child: Text( item['notification']!, style: const TextStyle(fontSize: 18.0), ), ), Padding( padding: const EdgeInsets.all(8.0), child: Text( item['createdby']!, style: const TextStyle(fontSize: 18.0), ), ), ]) ]), ], ), ), ), floatingActionButton: FloatingActionButton( backgroundColor: const Color.fromARGB(255, 11, 60, 144), onPressed: () { setState(() { // Update the list of table data rows tableDataRows = [ const TableRow( children: [ TableCell( child: Text('Row 1, Column 1 (updated)'), ), TableCell( child: Text('Row 1, Column 2 (updated)'), ), ], ), const TableRow( children: [ TableCell( child: Text('Row 2, Column 1 (updated)'), ), TableCell( child: Text('Row 2, Column 2 (updated)'), ), ], ), ]; }); }, child: const Icon(Icons.refresh), ), ), ); } }