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. CurrentCellActivatingCallback? onCurrentCellActivating,
  30. CurrentCellActivatedCallback? onCurrentCellActivated,
  31. DataGridCellTapCallback? onCellTap,
  32. DataGridCellDoubleTapCallback? onCellDoubleTap,
  33. DataGridCellTapCallback? onCellSecondaryTap,
  34. DataGridCellLongPressCallback? onCellLongPress,
  35. bool isScrollbarAlwaysShown = false,
  36. ScrollPhysics horizontalScrollPhysics = const AlwaysScrollableScrollPhysics(),
  37. ScrollPhysics verticalScrollPhysics = const AlwaysScrollableScrollPhysics(),
  38. LoadMoreViewBuilder? loadMoreViewBuilder,
  39. bool allowPullToRefresh = false,
  40. double refreshIndicatorDisplacement = 40.0,
  41. double refreshIndicatorStrokeWidth = 2.0,
  42. bool allowSwiping = false,
  43. double swipeMaxOffset = 200.0,
  44. ScrollController? horizontalScrollController,
  45. ScrollController? verticalScrollController,
  46. DataGridSwipeStartCallback? onSwipeStart,
  47. DataGridSwipeUpdateCallback? onSwipeUpdate,
  48. DataGridSwipeEndCallback? onSwipeEnd,
  49. DataGridSwipeActionsBuilder? startSwipeActionsBuilder,
  50. DataGridSwipeActionsBuilder? endSwipeActionsBuilder,
  51. bool highlightRowOnHover = true,
  52. bool allowColumnsResizing = false,
  53. ColumnResizeMode columnResizeMode = ColumnResizeMode.onResize,
  54. ColumnResizeStartCallback? onColumnResizeStart,
  55. ColumnResizeUpdateCallback? onColumnResizeUpdate,
  56. ColumnResizeEndCallback? onColumnResizeEnd,
  57. bool allowEditing = false,
  58. EditingGestureType editingGestureType = EditingGestureType.doubleTap,
  59. Widget? footer,
  60. double footerHeight = 49.0,
  61. bool showCheckboxColumn = false,
  62. DataGridCheckboxColumnSettings checkboxColumnSettings = const DataGridCheckboxColumnSettings(),
  63. List<GridTableSummaryRow> tableSummaryRows = const <GridTableSummaryRow>[],
  64. int? rowsPerPage,
  65. bool shrinkWrapColumns = false,
  66. bool shrinkWrapRows = false,
  67. int? rowsCacheExtent,
  68. bool allowFiltering = false,
  69. DataGridFilterChangingCallback? onFilterChanging,
  70. DataGridFilterChangedCallback? onFilterChanged,
  71. OutlinedBorder? checkboxShape,
  72. bool showHorizontalScrollbar = true,
  73. bool showVerticalScrollbar = true,
  74. bool allowColumnsDragging = false,
  75. DataGridColumnDraggingCallback? onColumnDragging,
  76. ColumnDragFeedbackBuilderCallback? columnDragFeedbackBuilder,
  77. bool showColumnHeaderIconOnHover = false,
  78. bool autoExpandGroups = true,
  79. bool allowExpandCollapseGroup = false,
  80. GroupChangingCallback? groupExpanding,
  81. GroupChangedCallback? groupExpanded,
  82. GroupChangingCallback? groupCollapsing,
  83. GroupChangedCallback? groupCollapsed,
  84. 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.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.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);