How to make DataTable Scroll Bidirectional. I made the datatable scroll Horizontally but my list is large and unable to scroll down.
@override Widget build(BuildContext context) { return Scaffold( appBar: AppBar(title: Text("Bills Receivable"),), body:SingleChildScrollView( scrollDirection: Axis.horizontal, child: DataTable( columns: <DataColumn>[ DataColumn(label:Text("BNm",style: TextStyle(fontWeight: FontWeight.bold),)), DataColumn(label:Text("BDt",style: TextStyle(fontWeight: FontWeight.bold),)), DataColumn(label:Text("BPrty",style: TextStyle(fontWeight: FontWeight.bold),)), DataColumn(label:Text("BdueDt",style: TextStyle(fontWeight: FontWeight.bold),)), DataColumn(label:Text("Dys",style: TextStyle(fontWeight: FontWeight.bold),)), DataColumn(label:Text("BAmt",style: TextStyle(fontWeight: FontWeight.bold),)), DataColumn(label:Text("BPAmt",style: TextStyle(fontWeight: FontWeight.bold),)), DataColumn(label:Text("BBAmt",style: TextStyle(fontWeight: FontWeight.bold),)) ], rows: widget.rdata.bRecDtl.map((e)=> DataRow( cells:<DataCell>[ DataCell(Text(e.bNm.toString())), DataCell(Text(e.bDt.toString())), DataCell(Text(e.bPrty.toString())), DataCell(Text(e.bdueDt.toString())), DataCell(Text(e.dys.toString())), DataCell(Text(e.bAmt.toString())), DataCell(Text(e.bPAmt.toString())), DataCell(Text(e.bBAmt.toString())), ])).toList() ), ), ); }
The Flutter DataTable provides support to scroll to a particular row and column programmatically. Also, provides options to perform horizontal or vertical scroll programmatically. Scroll programmatically to a particular row by passing the required row index in the scrollToRow method.
DataTables has the ability to show tables with horizontal scrolling, which is very useful for when you have a wide table, but want to constrain it to a limited horizontal display area. To enable x-scrolling simply set the scrollX parameter to be true .
Just add two SingleChildScrollView
s:
child: SingleChildScrollView( scrollDirection: Axis.vertical, child: SingleChildScrollView( scrollDirection: Axis.horizontal, child: DataTable()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With