Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make DataTable Scroll Bidirectional in Flutter

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()         ),       ),     );   } 
like image 250
kiran goud Avatar asked Mar 22 '19 12:03

kiran goud


People also ask

Is DataTable scrollable Flutter?

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.

How do you make a data table scrollable?

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 .


1 Answers

Just add two SingleChildScrollViews:

child: SingleChildScrollView(   scrollDirection: Axis.vertical,     child: SingleChildScrollView(       scrollDirection: Axis.horizontal,       child: DataTable() 
like image 141
Lucas Breitembach Avatar answered Sep 22 '22 05:09

Lucas Breitembach