NativeDataTable.fromJson constructor
NativeDataTable.fromJson({
- required List<
Map< items,String, dynamic> > - List<
String> ? columnKeys, - DataColumn columnBuilder(
- String key
- DataRow rowBuilder()?,
- DataCell cellBuilder(
- String key,
- dynamic value
- int rowsPerPage = PaginatedDataTable.defaultRowsPerPage,
- Widget? header,
- bool showSelect = true,
- bool showSort = true,
- ValueChanged<
int?> ? onRowsPerPageChanged, - ValueChanged<
bool?> ? onSelectAll, - bool? sortAscending,
- int? sortColumnIndex,
- IndexedWidgetBuilder? mobileItemBuilder,
- int? totalItems,
- Size tabletBreakpoint = _kTabletBreakpoint,
- List<
Widget> ? actions, - int firstRowIndex = 0,
- List<
Widget> ? selectedActions, - RefreshCallback? onRefresh,
- int mobileFetchNextRows = 100,
- VoidCallback? handlePrevious,
- VoidCallback? handleNext,
- bool rowCountApproximate = false,
- Widget? noItems,
- Widget? mobileIsLoading,
- List<
Widget> ? mobileSlivers, - bool alwaysShowDataTable = false,
Implementation
NativeDataTable.fromJson({
required List<Map<String, dynamic>> items,
List<String>? columnKeys,
DataColumn Function(String key)? columnBuilder,
DataRow Function(Map<String, dynamic> item)? rowBuilder,
DataCell Function(String key, dynamic value)? cellBuilder,
this.rowsPerPage = PaginatedDataTable.defaultRowsPerPage,
this.header,
this.showSelect = true,
this.showSort = true,
this.onRowsPerPageChanged,
this.onSelectAll,
this.sortAscending,
this.sortColumnIndex,
this.mobileItemBuilder,
this.totalItems,
this.tabletBreakpoint = _kTabletBreakpoint,
this.actions,
this.firstRowIndex = 0,
this.selectedActions,
this.onRefresh,
this.mobileFetchNextRows = 100,
this.handlePrevious,
this.handleNext,
this.rowCountApproximate = false,
this.noItems,
this.mobileIsLoading,
this.mobileSlivers,
this.alwaysShowDataTable = false,
}) : assert(items.isNotEmpty || columnKeys != null),
columns = (columnKeys ?? items[0].keys.toList()).map((e) {
if (columnBuilder != null) return columnBuilder(e);
return DataColumn(label: Text(e));
}).toList(),
rows = items.isEmpty
? []
: items.map((e) {
if (rowBuilder != null) return rowBuilder(e);
return DataRow(
cells: e.entries.map((e) {
if (cellBuilder != null) return cellBuilder(e.key, e.value);
return DataCell(Text(e.value.toString()));
}).toList());
}).toList();