flutter datatable
  sX9JkgY3DY86 2023年11月13日 17 0

 

@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: new ListView(
children: <Widget>[
new DataTable(columns: <DataColumn>[
new DataColumn(
label: new GestureDetector(
onTap: () {},
child: Text("报警时间"),
)),
new DataColumn(
label: new GestureDetector(
onTap: () {},
child: Text("报警信息"),
)),
], rows: <DataRow>[
new DataRow(cells: <DataCell>[
new DataCell(Text("棒材-粗轧轧机-主电机-前轴瓦-轴瓦温度过高,报警值41℃"), onTap: () {}),
new DataCell(Text("2019/05/7 8:32:06"), onTap: () {}),
]),
new DataRow(cells: <DataCell>[
new DataCell(Text("棒材-粗轧轧机-主电机-前轴瓦-轴瓦温度过高,报警值41℃"), onTap: () {}),
new DataCell(Text("2019/05/7 8:32:06"), onTap: () {}),
]),
])
],
)),
);
}

flutter datatable_Text

 

 

 

Widget waringTable() => DataTable(
columns: <DataColumn>[
DataColumn(
label: Text("报警时间"),
),
DataColumn(
label: Text("报警信息"),
)
],
rows: <DataRow>[
DataRow(cells: <DataCell>[
DataCell(Text("data")),
DataCell(Text("data")),
])
],
);

flutter datatable_ide_02

 

Widget waringTable() => DataTable(
columns: <DataColumn>[
DataColumn(
label: Text("报警时间"),
),
DataColumn(
label: Text("报警信息"),
)
],
rows: datas.map((name)=>DataRow(
cells: [
DataCell(Text(name.time)),
DataCell(Text(name.info))
]
)).toList()
);

class Name {
String time;
String info;
Name({this.time,this.info});
}

var names=<Name>[Name(time:"a",info:"b"),Name(time:"c",info:"d")];

 

Widget waringTable() => DataTable(
columns: <DataColumn>[
DataColumn(
label: Text("报警时间", textAlign: TextAlign.right),
),
DataColumn(
label: Text("报警信息"),
)
],
rows: list
?.map((name) => DataRow(cells: [
DataCell(Text(name.alarmTime, softWrap: true)),
DataCell(Text(name.alarmMsg, softWrap: true))
]))
?.toList() ??
[]);

 

 

class WaringDataSource extends DataTableSource {
List<Name> _posts = list;
int _selectedCount = 0;
@override
int get rowCount => _posts.length;

@override
bool get isRowCountApproximate => false;

@override
int get selectedRowCount => _selectedCount;

@override
DataRow getRow(int index) {
Name name = _posts[index];
return DataRow.byIndex(index: index, cells: <DataCell>[
DataCell(Text(name.alarmMsg, softWrap: true)),
DataCell(Text(name.alarmTime, softWrap: true)),
]);
}
}

 

Widget waringTable() => PaginatedDataTable(
header: Text(""),
source: _waringSource,
rowsPerPage: 5,
columns: <DataColumn>[
DataColumn(
label: Text("报警信息"),
),
DataColumn(
label: Text("报警时间", textAlign: TextAlign.right),
)
],
);

 



【版权声明】本文内容来自摩杜云社区用户原创、第三方投稿、转载,内容版权归原作者所有。本网站的目的在于传递更多信息,不拥有版权,亦不承担相应法律责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@moduyun.com

上一篇: flutter layout-child 下一篇: flutter 修饰盒子
  1. 分享:
最后一次编辑于 2023年11月13日 0

暂无评论

推荐阅读
  b1UHV4WKBb2S   2023年11月13日   24   0   0 ide抗锯齿
  b1UHV4WKBb2S   2023年11月13日   21   0   0 裁剪ideflutter
  zSWNgACtCQuP   2023年11月13日   19   0   0 ide
sX9JkgY3DY86