Skip to content

Instantly share code, notes, and snippets.

@kirshiyin89
Last active September 30, 2020 18:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kirshiyin89/459308e6ea8df11480758a11e9f62e8d to your computer and use it in GitHub Desktop.
Save kirshiyin89/459308e6ea8df11480758a11e9f62e8d to your computer and use it in GitHub Desktop.
generate the data table columns
List<DataColumn> generateDataColumns() {
return const <DataColumn>[
DataColumn(
label: Text(
'Name',
style: TextStyle(fontStyle: FontStyle.italic),
),
),
DataColumn(
label: Text(
'Value',
style: TextStyle(fontStyle: FontStyle.italic),
),
),
];
}
List<DataRow> generateDataRows(BuildContext context, List<ConfigData> data) {
return data.map((element) => getRow(element)).toList();
}
DataRow getRow(ConfigData element) {
return DataRow(
cells: <DataCell>[
DataCell(Text(element.name)),
DataCell(
TextFormField(
initialValue: element.value,
keyboardType: TextInputType.name,
onFieldSubmitted: (val) {
element.value = val;
setConfigValue(element);
},
),
showEditIcon: true),
],
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment