import 'package:discover_module/custom_widget/floating_btn.dart'; import 'package:discover_module/custom_widget/show_alert.dart'; import 'package:discover_module/hive_fun.dart'; import 'package:discover_module/ui_screen/ranking.dart'; import 'package:flutter/material.dart'; class RisingStar extends StatefulWidget { const RisingStar({super.key}); @override State createState() => RisingStarState(); } class RisingStarState extends State { late _DataSource _dataSource; @override void initState() { // TODO: implement initState super.initState(); _dataSource = _DataSource(context); } @override Widget build(BuildContext context) { 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: true, // 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('Specialty', 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('Discover Rank', style: TextStyle( fontWeight: FontWeight.bold, fontSize: 14.0, fontStyle: FontStyle.normal))), DataColumn( label: Text('Indicator', style: TextStyle( fontWeight: FontWeight.bold, fontSize: 14.0, fontStyle: FontStyle.normal))), DataColumn( label: Text('Previous year \n (2018-2022)', style: TextStyle( fontWeight: FontWeight.bold, fontSize: 14.0, fontStyle: FontStyle.normal))), DataColumn( label: Text('Current year \n (2022-2024)', style: TextStyle( fontWeight: FontWeight.bold, fontSize: 14.0, fontStyle: FontStyle.normal))), DataColumn( label: Text('Status', style: TextStyle( fontWeight: FontWeight.bold, fontSize: 14.0, fontStyle: FontStyle.normal))), ], source: _dataSource, ), ], ), floatingActionButton: Visibility( visible: true, child: FloatingBtn( icon: Icons.add, title: "add", onTap: () { List selectedRowIds = _dataSource.getSelectedRowIds(); // Do something with selectedRowIds print('Selected Row IDstrndsss: $selectedRowIds'); for (int i = 0; i < selectedRowIds.length; i++) { print("checking_value_istrends: ${selectedRowIds[i]}"); // _contactbox.put(i, selectedRowIds[i]); HiveFunctions.createUser({ "name": selectedRowIds[i], "org": "Azienda Ospedaliera di Padova", "adrr": "Via Giustiniani 2, Padova, Veneto 35128, Italy", "phone": "+390498212410X12", "Pphone": "+390498212410X12", "email": "Gerosa,Gino@gmail.com", "affno": "75", "eveno": "8", "pubno": "251", "trailno": "1" }); } showDialog( context: context, builder: (_) { return Alert( data: "User Added Successfully", onPressed: () { Navigator.of(context).pop(); }, ); }); }, )), ), ); } } class _Row { _Row(this.i, this.valueA, this.valueC, this.valueD, this.valueE, this.valueF, this.valueG, this.valueH, this.valueI); final int i; final String valueA; final String valueC; final String 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; final List _selectedRowIds = []; _DataSource(this.context) { _rows = <_Row>[ for (int i = 0; i < 20; i++) _Row(i, 'Gerosa, Gino', 'Cardiology', '1', '0', '0', 'Tier 1', 'Tier 1', ''), ]; //} } List getSelectedRowIds() { return _selectedRowIds; // Return a copy to prevent direct modification } 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"); // Navigator.push( if (row.selected != value) { // _selectedCount += value! ? 1 : -1; // assert(_selectedCount >= 0); row.selected = value!; if (value) { print("Selected"); _selectedRowIds.add(row.valueA); // Add the row ID to the list print("Selected_selectedRowIds :$_selectedRowIds"); } else { _selectedRowIds .remove(row.valueA); // Remove the row ID from the list } notifyListeners(); print("Selectedddd_is $value"); print("Selectedddd_value ${row.valueA}"); } // context, MaterialPageRoute(builder: (context) => Profile())); }, cells: [ DataCell(Text(row.valueA)), 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; }