DiscoverModule/lib/ui_screen/listview.dart

181 lines
6.1 KiB
Dart
Raw Normal View History

2024-05-20 10:29:02 +00:00
import 'package:flutter/material.dart';
class DataTableDemo extends StatefulWidget {
@override
State<DataTableDemo> createState() => _DataTableDemoState();
}
class _DataTableDemoState extends State<DataTableDemo> {
Widget build(BuildContext context) {
2024-06-10 11:11:00 +00:00
return SafeArea(
child: Scaffold(
body: ListView(
padding: const EdgeInsets.all(3),
children: [
PaginatedDataTable(
header: const Text(
'HCP RANKING',
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 18.0,
fontStyle: FontStyle.normal),
),
showFirstLastButtons: true,
showEmptyRows: false,
showCheckboxColumn: false,
// actions: const [Text("jii")],
rowsPerPage: 5,
columns: const [
DataColumn(
label: Text('Name',
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 14.0,
fontStyle: FontStyle.normal))),
DataColumn(
label: Text('Opt-in Status',
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 14.0,
fontStyle: FontStyle.normal))),
DataColumn(
label: Text('Country',
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 14.0,
fontStyle: FontStyle.normal))),
DataColumn(
label: Text('Rank',
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 14.0,
fontStyle: FontStyle.normal))),
DataColumn(
label: Text('Score',
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 14.0,
fontStyle: FontStyle.normal))),
DataColumn(
label: Text('Event',
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 14.0,
fontStyle: FontStyle.normal))),
DataColumn(
label: Text('Affliations',
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 14.0,
fontStyle: FontStyle.normal))),
DataColumn(
label: Text('Publications',
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 14.0,
fontStyle: FontStyle.normal))),
DataColumn(
label: Text('Trails',
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 14.0,
fontStyle: FontStyle.normal))),
],
source: _DataSource(context),
2024-05-20 10:29:02 +00:00
),
2024-06-10 11:11:00 +00:00
],
),
2024-05-20 10:29:02 +00:00
),
);
}
}
class _Row {
2024-06-27 08:38:43 +00:00
_Row(this.identifier, this.valueA, this.valueB, this.valueC, this.valueD,
this.valueE, this.valueF, this.valueG, this.valueH, this.valueI);
final String identifier;
2024-05-20 10:29:02 +00:00
final String valueA;
final String valueB;
final String valueC;
final int valueD;
final String valueE;
final String valueF;
final String valueG;
final String valueH;
final String valueI;
bool selected = false;
}
class _DataSource extends DataTableSource {
final BuildContext context;
late List<_Row> _rows;
_DataSource(this.context) {
// _rows = <_Row>[
// _Row('Cell A1', 'CellB1', 'CellC1', 1, 'CellE1', 'CellF1', 'CellG1',
// 'CellH1', 'CellI1'),
// _Row('Cell A2', 'CellB2', 'CellC2', 2, 'CellE1', 'CellF1', 'CellG1',
// 'CellH1', 'CellI1'),
// _Row('Cell A3', 'CellB3', 'CellC3', 3, 'CellE1', 'CellF1', 'CellG1',
// 'CellH1', 'CellI1'),
// _Row('Cell A4', 'CellB4', 'CellC4', 4, 'CellE1', 'CellF1', 'CellG1',
// 'CellH1', 'CellI1'),
// _Row('Cell A5', 'CellB1', 'CellC1', 1, 'CellE1', 'CellF1', 'CellG1',
// 'CellH1', 'CellI1'),
// _Row('Cell A6', 'CellB2', 'CellC2', 2, 'CellE1', 'CellF1', 'CellG1',
// 'CellH1', 'CellI1'),
// _Row('Cell A7', 'CellB3', 'CellC3', 3, 'CellE1', 'CellF1', 'CellG1',
// 'CellH1', 'CellI1'),
// _Row('Cell A8', 'CellB4', 'CellC4', 4, 'CellE1', 'CellF1', 'CellG1',
// 'CellH1', 'CellI1'),
// _Row('Cell A9', 'CellB1', 'CellC1', 1, 'CellE1', 'CellF1', 'CellG1',
// 'CellH1', 'CellI1'),
// ];
_rows = <_Row>[
for (int i = 0; i < 20; i++)
2024-06-27 08:38:43 +00:00
_Row('$i', 'Gerosa, Gino', 'Active', 'Italy', 1, '0', '0', '0', '0',
'0'),
2024-05-20 10:29:02 +00:00
];
//}
}
int _selectedCount = 0;
@override
DataRow? getRow(int index) {
assert(index >= 0);
if (index >= _rows.length) return null;
final row = _rows[index];
return DataRow.byIndex(
index: index,
selected: row.selected,
onSelectChanged: (value) {
// print("hii");
2024-06-28 08:14:42 +00:00
// Navigator.push(
// context, MaterialPageRoute(builder: (context) => Profile()));
2024-05-20 10:29:02 +00:00
},
cells: [
DataCell(Text(row.valueA)),
DataCell(Text(row.valueB)),
DataCell(Text(row.valueC)),
DataCell(Text(row.valueD.toString())),
DataCell(Text(row.valueE)),
DataCell(Text(row.valueF)),
DataCell(Text(row.valueG)),
DataCell(Text(row.valueH)),
DataCell(Text(row.valueI)),
],
);
}
@override
int get rowCount => _rows.length;
@override
bool get isRowCountApproximate => false;
@override
int get selectedRowCount => _selectedCount;
}