SfDataGrid constructor

const SfDataGrid({
  1. required DataGridSource source,
  2. required List<GridColumn> columns,
  3. Key? key,
  4. double rowHeight = double.nan,
  5. double headerRowHeight = double.nan,
  6. double defaultColumnWidth = double.nan,
  7. GridLinesVisibility gridLinesVisibility = GridLinesVisibility.horizontal,
  8. GridLinesVisibility headerGridLinesVisibility = GridLinesVisibility.horizontal,
  9. ColumnWidthMode columnWidthMode = ColumnWidthMode.none,
  10. ColumnSizer? columnSizer,
  11. ColumnWidthCalculationRange columnWidthCalculationRange = ColumnWidthCalculationRange.visibleRows,
  12. SelectionMode selectionMode = SelectionMode.none,
  13. GridNavigationMode navigationMode = GridNavigationMode.row,
  14. int frozenColumnsCount = 0,
  15. int footerFrozenColumnsCount = 0,
  16. int frozenRowsCount = 0,
  17. int footerFrozenRowsCount = 0,
  18. bool allowSorting = false,
  19. bool allowMultiColumnSorting = false,
  20. bool allowTriStateSorting = false,
  21. bool showSortNumbers = false,
  22. SortingGestureType sortingGestureType = SortingGestureType.tap,
  23. List<StackedHeaderRow> stackedHeaderRows = const <StackedHeaderRow>[],
  24. SelectionManagerBase? selectionManager,
  25. DataGridController? controller,
  26. QueryRowHeightCallback? onQueryRowHeight,
  27. SelectionChangedCallback? onSelectionChanged,
  28. SelectionChangingCallback? onSelectionChanging,
  29. DataGridCheckboxValueChangedCallback? onCheckboxValueChanged,
  30. DataGridColumnSortChangingCallback? onColumnSortChanging,
  31. DataGridColumnSortChangedCallback? onColumnSortChanged,
  32. CurrentCellActivatingCallback? onCurrentCellActivating,
  33. CurrentCellActivatedCallback? onCurrentCellActivated,
  34. DataGridCellTapCallback? onCellTap,
  35. DataGridCellDoubleTapCallback? onCellDoubleTap,
  36. DataGridCellTapCallback? onCellSecondaryTap,
  37. DataGridCellLongPressCallback? onCellLongPress,
  38. bool isScrollbarAlwaysShown = false,
  39. ScrollPhysics horizontalScrollPhysics = const AlwaysScrollableScrollPhysics(),
  40. ScrollPhysics verticalScrollPhysics = const AlwaysScrollableScrollPhysics(),
  41. LoadMoreViewBuilder? loadMoreViewBuilder,
  42. bool allowPullToRefresh = false,
  43. double refreshIndicatorDisplacement = 40.0,
  44. double refreshIndicatorStrokeWidth = 2.0,
  45. bool allowSwiping = false,
  46. double swipeMaxOffset = 200.0,
  47. ScrollController? horizontalScrollController,
  48. ScrollController? verticalScrollController,
  49. DataGridSwipeStartCallback? onSwipeStart,
  50. DataGridSwipeUpdateCallback? onSwipeUpdate,
  51. DataGridSwipeEndCallback? onSwipeEnd,
  52. DataGridSwipeActionsBuilder? startSwipeActionsBuilder,
  53. DataGridSwipeActionsBuilder? endSwipeActionsBuilder,
  54. bool highlightRowOnHover = true,
  55. bool allowColumnsResizing = false,
  56. ColumnResizeMode columnResizeMode = ColumnResizeMode.onResize,
  57. ColumnResizeStartCallback? onColumnResizeStart,
  58. ColumnResizeUpdateCallback? onColumnResizeUpdate,
  59. ColumnResizeEndCallback? onColumnResizeEnd,
  60. bool allowEditing = false,
  61. EditingGestureType editingGestureType = EditingGestureType.doubleTap,
  62. Widget? placeholder,
  63. Widget? footer,
  64. double footerHeight = 49.0,
  65. bool showCheckboxColumn = false,
  66. DataGridCheckboxColumnSettings checkboxColumnSettings = const DataGridCheckboxColumnSettings(),
  67. List<GridTableSummaryRow> tableSummaryRows = const <GridTableSummaryRow>[],
  68. int? rowsPerPage,
  69. bool shrinkWrapColumns = false,
  70. bool shrinkWrapRows = false,
  71. int? rowsCacheExtent,
  72. bool allowFiltering = false,
  73. DataGridFilterChangingCallback? onFilterChanging,
  74. DataGridFilterChangedCallback? onFilterChanged,
  75. OutlinedBorder? checkboxShape,
  76. bool showHorizontalScrollbar = true,
  77. bool showVerticalScrollbar = true,
  78. bool allowColumnsDragging = false,
  79. DataGridColumnDraggingCallback? onColumnDragging,
  80. ColumnDragFeedbackBuilderCallback? columnDragFeedbackBuilder,
  81. bool showColumnHeaderIconOnHover = false,
  82. bool autoExpandGroups = true,
  83. bool allowExpandCollapseGroup = false,
  84. GroupChangingCallback? groupExpanding,
  85. GroupChangedCallback? groupExpanded,
  86. GroupChangingCallback? groupCollapsing,
  87. GroupChangedCallback? groupCollapsed,
  88. String groupCaptionTitleFormat = '{ColumnName} : {Key} - {ItemsCount} Items',
})

Creates a widget describing a datagrid.

The columns and source argument must be defined and must not be null.

Implementation

const SfDataGrid({
  required this.source,
  required this.columns,
  Key? key,
  this.rowHeight = double.nan,
  this.headerRowHeight = double.nan,
  this.defaultColumnWidth = double.nan,
  this.gridLinesVisibility = GridLinesVisibility.horizontal,
  this.headerGridLinesVisibility = GridLinesVisibility.horizontal,
  this.columnWidthMode = ColumnWidthMode.none,
  this.columnSizer,
  this.columnWidthCalculationRange = ColumnWidthCalculationRange.visibleRows,
  this.selectionMode = SelectionMode.none,
  this.navigationMode = GridNavigationMode.row,
  this.frozenColumnsCount = 0,
  this.footerFrozenColumnsCount = 0,
  this.frozenRowsCount = 0,
  this.footerFrozenRowsCount = 0,
  this.allowSorting = false,
  this.allowMultiColumnSorting = false,
  this.allowTriStateSorting = false,
  this.showSortNumbers = false,
  this.sortingGestureType = SortingGestureType.tap,
  this.stackedHeaderRows = const <StackedHeaderRow>[],
  this.selectionManager,
  this.controller,
  this.onQueryRowHeight,
  this.onSelectionChanged,
  this.onSelectionChanging,
  this.onCheckboxValueChanged,
  this.onColumnSortChanging,
  this.onColumnSortChanged,
  this.onCurrentCellActivating,
  this.onCurrentCellActivated,
  this.onCellTap,
  this.onCellDoubleTap,
  this.onCellSecondaryTap,
  this.onCellLongPress,
  this.isScrollbarAlwaysShown = false,
  this.horizontalScrollPhysics = const AlwaysScrollableScrollPhysics(),
  this.verticalScrollPhysics = const AlwaysScrollableScrollPhysics(),
  this.loadMoreViewBuilder,
  this.allowPullToRefresh = false,
  this.refreshIndicatorDisplacement = 40.0,
  this.refreshIndicatorStrokeWidth = 2.0,
  this.allowSwiping = false,
  this.swipeMaxOffset = 200.0,
  this.horizontalScrollController,
  this.verticalScrollController,
  this.onSwipeStart,
  this.onSwipeUpdate,
  this.onSwipeEnd,
  this.startSwipeActionsBuilder,
  this.endSwipeActionsBuilder,
  this.highlightRowOnHover = true,
  this.allowColumnsResizing = false,
  this.columnResizeMode = ColumnResizeMode.onResize,
  this.onColumnResizeStart,
  this.onColumnResizeUpdate,
  this.onColumnResizeEnd,
  this.allowEditing = false,
  this.editingGestureType = EditingGestureType.doubleTap,
  this.placeholder,
  this.footer,
  this.footerHeight = 49.0,
  this.showCheckboxColumn = false,
  this.checkboxColumnSettings = const DataGridCheckboxColumnSettings(),
  this.tableSummaryRows = const <GridTableSummaryRow>[],
  this.rowsPerPage,
  this.shrinkWrapColumns = false,
  this.shrinkWrapRows = false,
  this.rowsCacheExtent,
  this.allowFiltering = false,
  this.onFilterChanging,
  this.onFilterChanged,
  this.checkboxShape,
  this.showHorizontalScrollbar = true,
  this.showVerticalScrollbar = true,
  this.allowColumnsDragging = false,
  this.onColumnDragging,
  this.columnDragFeedbackBuilder,
  this.showColumnHeaderIconOnHover = false,
  this.autoExpandGroups = true,
  this.allowExpandCollapseGroup = false,
  this.groupExpanding,
  this.groupExpanded,
  this.groupCollapsing,
  this.groupCollapsed,
  this.groupCaptionTitleFormat = '{ColumnName} : {Key} - {ItemsCount} Items',
}) : assert(frozenColumnsCount >= 0),
     assert(footerFrozenColumnsCount >= 0),
     assert(frozenRowsCount >= 0),
     assert(footerFrozenRowsCount >= 0),
     super(key: key);