本文介绍了展开DataTable以填充Flutter中的高度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我对扑打有疑问.我需要在屏幕高度处填充一个数据表.
I have a problem with flutter.I need to fill a DataTable in the height of screen.
我试图将dataTable添加到Flex小部件中,但没有得到任何更改.
I tried to add the dataTable inside a Flex widget, but I don't get changes.
当我设置容器的高度时,这项工作使我在屏幕的按钮处留有空白
When I set the heigh of the Container, that's work let me a white space at the button of the screen
谢谢!我为我的英语不好对不起
Thank you! and i'm sorry for mi poor english
这是我的代码:
products.addAll(Product.getExampleList());
var table =
Container(
child: SingleChildScrollView(
scrollDirection: Axis.horizontal,
child:SizedBox(
child:
Column(
children: <Widget>[
DataTable(
columns: <DataColumn>[
DataColumn(
label: Text("Código")
),
DataColumn(
label: Text("Precio"),
numeric: true,
),
DataColumn(
label: Text("Grupo")
),
DataColumn(
label: Text("Descripción")
),
],
rows:
products.map<DataRow>((Product element) {
return DataRow(
key: Key(element.idProduct.toString()),
cells: <DataCell>[
DataCell(Text(element.code)),
DataCell(Text("\$ " + element.price.toStringAsFixed(2))),
DataCell(Text(element.group)),
DataCell(Text(element.description))
],
);
}).toList()
),
],
)
),
),
);
return Container(
color: Colors.white24,
child:
Column(
children: <Widget>[
Container(
padding: EdgeInsets.all(10),
child: Row(
children: <Widget>[
Text("Código: "),
Flexible(
child: TextField(
controller: tController,
decoration: InputDecoration(
hintText: "Ingrese Código"
) ,
),
),
RaisedButton(
onPressed: onPressedSearch,
child: Text("Buscar"),
)
],
),
),
Flex(
direction: Axis.vertical,
children: <Widget>[
table
],
),
],
)
);
推荐答案
您可以设置DataTable的dataRowHeight和headingRowHeight属性,使其高度等于屏幕高度.
You can set the dataRowHeight and headingRowHeight properties of the DataTable to make its height equal to screen height.
your_number_of_rows = 4;
rowHeight = (MediaQuery.of(context).size.height - 56) / your_number_of_rows;
DataTable(dataRowHeight: rowHeight, headingRowHeight: 56.0, columns: ...)
这篇关于展开DataTable以填充Flutter中的高度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!