如何在Flutter中使用`SingleChildScrollView`小部件在`DataTable`中应用水平和垂直滚动?

时间:2020-04-11 10:45:10

标签: flutter

我有一个数据表,它的水平和垂直方向都超出了屏幕大小,因此我需要同时使用垂直和水平滚动。 我使用了这段代码:

SingleChildScrollView(
  scrollDirection: Axis.horizontal,
  child: SingleChildScrollView(
    scrollDirection: Axis.vertical,
    child: DataTable(
      columns: [
        DataColumn(label: Text('Vis_Code')),
        DataColumn(label: Text('Vis_Name')),
        DataColumn(label: Text('ID_Voucher')),
        DataColumn(label: Text('Voucher_Type_Title')),
        DataColumn(label: Text('Stock_Title')),
        DataColumn(label: Text('Date_Voucher')),
        DataColumn(label: Text('Customer_Name')),
        DataColumn(label: Text('Good_Title')),
        DataColumn(label: Text('Meghdar_F')),
        DataColumn(label: Text('Price_Kol_F')),
      ],
      rows:
          littlevouchers element
              .map(
                ((element) => DataRow(
                  cells: <DataCell>[
                    DataCell(Text(element["Vis_Code"])), 
                    DataCell(Text(element["Vis_Name"])),
                    DataCell(Text(element["ID_Voucher"])),
                    DataCell(Text(element["Voucher_Type_Title"])),
                    DataCell(Text(element["Stock_Title"])),
                    DataCell(Text(element["Date_Voucher"])),
                    DataCell(Text(element["Customer_Name"])),
                    DataCell(Text(element["Good_Title"])),
                    DataCell(Text(element["Meghdar_F"])),
                    DataCell(Text(element["Price_Kol_F"])),
                  ],
                )),
              )
              .toList(),
    ),
  ),
),

但是颤动只是应用了水平滚动。

此外,DataTable溢出了屏幕底部。并引发以下错误:

A RenderFlex overflowed by 30 pixels on the bottom.

你有什么主意吗?

0 个答案:

没有答案