import 'package:discover_module/provider_class/affiliationsprovider.dart'; import 'package:discover_module/provider_class/events_provider.dart'; import 'package:discover_module/provider_class/publications_provider.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; class EventsData extends StatefulWidget { const EventsData({super.key}); @override State createState() => _EventsDataState(); } class _EventsDataState extends State { List hcppublication = []; @override void initState() { // TODO: implement initState super.initState(); affdata(); } affdata() async { final affprovider = Provider.of(context, listen: false); await affprovider.allgeteventdata(); final affdata = affprovider.allEventsList; setState(() { hcppublication = affdata; }); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text('Publications'), ), body: Scrollbar( child: SingleChildScrollView( scrollDirection: Axis.horizontal, child: Container( constraints: BoxConstraints(minWidth: MediaQuery.of(context).size.width), child: DataTable( columns: const [ DataColumn( label: Expanded(child: Text('sl no', softWrap: true))), DataColumn( label: Expanded( child: Text('Event Name', softWrap: true), )), DataColumn( label: Expanded( child: Text('Session Type', softWrap: true))), DataColumn( label: Expanded(child: Text('Topic', softWrap: true))), DataColumn( label: Expanded(child: Text('Role', softWrap: true))), // Add more columns as needed ], rows: List.generate( hcppublication.length, (index) => DataRow( cells: [ DataCell(Text(hcppublication[index]['id'].toString(), softWrap: true)), DataCell(Text( hcppublication[index]['event_name'].toString(), softWrap: true)), DataCell(Text( hcppublication[index]['session_type'].toString(), softWrap: true)), DataCell(Text(hcppublication[index]['topic'].toString(), softWrap: true)), DataCell(Text(hcppublication[index]['role'].toString(), softWrap: true)), // Add more DataCells as needed ], ), ), ), ), ), )); } }