Seb*_*rdi 11 datatable fill dart flutter
我遇到了抖动问题。\n我需要在屏幕高度填充数据表。
\n我尝试在 Flex 小部件中添加 dataTable,但没有得到任何更改。
\n当我设置容器的高度时,让我在屏幕按钮处留出一个空白区域
\n谢谢你!我很抱歉我的英语很差
\n这是我的代码:
\nproducts.addAll(Product.getExampleList());\n\nvar table =\n\nContainer(\n child: SingleChildScrollView(\n scrollDirection: Axis.horizontal,\n child:SizedBox(\n child:\n Column(\n children: <Widget>[\n DataTable(\n columns: <DataColumn>[\n DataColumn(\n label: Text("C\xc3\xb3digo")\n ),\n DataColumn(\n label: Text("Precio"),\n numeric: true,\n ),\n DataColumn(\n label: Text("Grupo")\n ),\n DataColumn(\n label: Text("Descripci\xc3\xb3n")\n ),\n ],\n rows:\n products.map<DataRow>((Product element) {\n return DataRow(\n key: Key(element.idProduct.toString()),\n cells: <DataCell>[\n DataCell(Text(element.code)),\n DataCell(Text("\\$ " + element.price.toStringAsFixed(2))),\n DataCell(Text(element.group)),\n DataCell(Text(element.description))\n ],\n );\n }).toList()\n ),\n ],\n )\n ),\n ),\n);\n\n\nreturn Container(\n color: Colors.white24,\n child:\n Column(\n children: <Widget>[\n Container(\n padding: EdgeInsets.all(10),\n child: Row(\n\n children: <Widget>[\n\n Text("C\xc3\xb3digo: "),\n Flexible(\n child: TextField(\n controller: tController,\n decoration: InputDecoration(\n hintText: "Ingrese C\xc3\xb3digo"\n ) ,\n ),\n ),\n RaisedButton(\n onPressed: onPressedSearch,\n child: Text("Buscar"),\n )\n ],\n ),\n ),\n Flex(\n direction: Axis.vertical,\n children: <Widget>[\n table\n ],\n ),\n ],\n )\n);\nRun Code Online (Sandbox Code Playgroud)\n
Mut*_*sek 16
您可以设置 的dataRowHeight和headingRowHeight属性,DataTable使其高度等于屏幕高度。
your_number_of_rows = 4;
rowHeight = (MediaQuery.of(context).size.height - 56) / your_number_of_rows;
DataTable(dataRowHeight: rowHeight, headingRowHeight: 56.0, columns: ...)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
16883 次 |
| 最近记录: |