NativeDataTable.fromJson constructor

NativeDataTable.fromJson({
  1. required List<Map<String, dynamic>> items,
  2. List<String>? columnKeys,
  3. DataColumn columnBuilder(
    1. String key
    )?,
  4. DataRow rowBuilder(
    1. Map<String, dynamic> item
    )?,
  5. DataCell cellBuilder(
    1. String key,
    2. dynamic value
    )?,
  6. int rowsPerPage = PaginatedDataTable.defaultRowsPerPage,
  7. Widget? header,
  8. bool showSelect = true,
  9. bool showSort = true,
  10. ValueChanged<int?>? onRowsPerPageChanged,
  11. ValueChanged<bool?>? onSelectAll,
  12. bool? sortAscending,
  13. int? sortColumnIndex,
  14. IndexedWidgetBuilder? mobileItemBuilder,
  15. int? totalItems,
  16. Size tabletBreakpoint = _kTabletBreakpoint,
  17. List<Widget>? actions,
  18. int firstRowIndex = 0,
  19. List<Widget>? selectedActions,
  20. RefreshCallback? onRefresh,
  21. int mobileFetchNextRows = 100,
  22. VoidCallback? handlePrevious,
  23. VoidCallback? handleNext,
  24. bool rowCountApproximate = false,
  25. Widget? noItems,
  26. Widget? mobileIsLoading,
  27. List<Widget>? mobileSlivers,
  28. 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();