DataTable class

An enhanced version of Flutter's standard DataTable with additional features.

DataTable provides an improved data table implementation with fixed headers, fixed columns, column sizing, and improved performance for large datasets. It extends Flutter's standard DataTable with several advanced features:

  • Fixed headers that remain visible when scrolling vertically
  • Fixed left columns that remain visible when scrolling horizontally
  • Customizable column widths with S, M, L sizing options
  • Fixed width columns
  • Row-level tap events
  • Specific row heights
  • Enhanced styling options

See also:

  • doc/component/data_table.md for more detailed documentation
  • DataColumn, which configures column properties
  • DataRow, which configures row properties
Inheritance
Available extensions

Constructors

DataTable.new({Key? key, required List<DataColumn> columns, int? sortColumnIndex, bool sortAscending = true, ValueSetter<bool?>? onSelectAll, Decoration? decoration, MaterialStateProperty<Color?>? dataRowColor, double? dataRowHeight, TextStyle? dataTextStyle, MaterialStateProperty<Color?>? headingRowColor, Color? fixedColumnsColor, Color? fixedCornerColor, double? headingRowHeight, TextStyle? headingTextStyle, CheckboxThemeData? headingCheckboxTheme, CheckboxThemeData? datarowCheckboxTheme, double? horizontalMargin, double? checkboxHorizontalMargin, Alignment checkboxAlignment = Alignment.center, double? bottomMargin, double? columnSpacing, bool showHeadingCheckBox = true, bool showCheckboxColumn = true, bool showBottomBorder = false, double? dividerThickness, Clip clipBehavior = Clip.none, double? minWidth, ScrollController? scrollController, ScrollController? horizontalScrollController, bool? isVerticalScrollBarVisible = false, bool? isHorizontalScrollBarVisible = true, Widget? empty, TableBorder? border, double smRatio = 0.67, int fixedTopRows = 1, int fixedLeftColumns = 0, double lmRatio = 1.2, Duration sortArrowAnimationDuration = const Duration(milliseconds: 150), IconData sortArrowIcon = Icons.arrow_upward, Widget? sortArrowBuilder(bool ascending, bool sorted)?, BoxDecoration? headingRowDecoration, required List<DataRow> rows})

Properties

asBuilder NeverWidgetBuilder

Available on Widget, provided by the WidgetExtension extension

no setter
asSliver Widget

Available on Widget, provided by the XWidgetArcane extension

no setter
ast Widget

Available on Widget, provided by the XAST extension

no setter
base TextModifier

Available on Widget, provided by the TextExtension extension

no setter
black TextModifier

Available on Widget, provided by the TextExtension extension

no setter
blockQuote TextModifier

Available on Widget, provided by the TextExtension extension

no setter
blurIn Widget

Available on Widget, provided by the XWidgetEffect extension

no setter
bold TextModifier

Available on Widget, provided by the TextExtension extension

no setter
border TableBorder?
Set vertical and horizontal borders between cells, as well as outside borders around table.
final
bottomMargin double?
If set the table will have empty space added after the the last row and allow scroll the core of the table higher (e.g. if you would like to have iOS navigation UI at the bottom overlapping the table and have the ability to slightly scroll up the bototm row to avoid the obstruction)
final
centered Widget

Available on Widget, provided by the XWidget extension

no setter
checkboxAlignment Alignment
Alignment of the checkbox if it is displayed Defaults to the Alignment.center
final
checkboxHorizontalMargin double?
Horizontal margin around the checkbox, if it is displayed.
finalinherited
clipBehavior Clip
The content will be clipped (or not) according to this option.
finalinherited
columns List<DataColumn>
The configuration and labels for the columns in the table.
finalinherited
columnSpacing double?
The horizontal margin between the contents of each data column.
finalinherited
datarowCheckboxTheme CheckboxThemeData?
Overrides theme of the checkbox that is displayed in the checkbox column in each data row (should checkboxes be enabled)
final
dataRowColor MaterialStateProperty<Color?>?
The background color for the data rows.
finalinherited
dataRowHeight double?
The height of each row (excluding the row that contains column headings).
final
dataRowMaxHeight double?
The maximum height of each row (excluding the row that contains column headings).
finalinherited
dataRowMinHeight double?
The minimum height of each row (excluding the row that contains column headings).
finalinherited
dataTextStyle TextStyle?
The text style for data rows.
finalinherited
decoration Decoration?
The background and border decoration for the table.
finalinherited
dividerThickness double?
The width of the divider that appears between TableRows.
finalinherited
ellipsis TextModifier

Available on Widget, provided by the TextExtension extension

no setter
empty Widget?
Placeholder widget which is displayed whenever the data rows are empty. The widget will be displayed below column
final
expand Widget

Available on Widget, provided by the XWidget extension

no setter
extraBold TextModifier

Available on Widget, provided by the TextExtension extension

no setter
extraLight TextModifier

Available on Widget, provided by the TextExtension extension

no setter
firstP TextModifier

Available on Widget, provided by the TextExtension extension

no setter
fixedColumnsColor Color?
Backgound color of the sticky columns fixed via fixedLeftColumns. Note: unlike data rows which can change their colors depending on material state (e.g. selected, hovered) this color is static and doesn't repond to state change Note: to change background color of fixed data rows use DataTable.headingRowColor
final
fixedCornerColor Color?
Backgound color of the top left corner which is fixed whenere both fixedTopRows and fixedLeftColumns are greater than 0 Note: unlike data rows which can change their colors depending on material state (e.g. selected, hovered) this color is static and doesn't repond to state change Note: to change background color of fixed data rows use DataTable.headingRowColor
final
fixedLeftColumns int
Number of sticky columns fixed at the left side of the table. Check box column (if enabled) is also counted
final
fixedTopRows int
The number of sticky rows fixed at the top of the table. The heading row is counted/included. By defult the value is 1 which means header row is fixed. Set to 0 in order to unstick the header, set to >1 in order to fix data rows (i.e. in order to fix both header and the first data row use value of 2)
final
flexible Widget

Available on Widget, provided by the XWidget extension

no setter
foreground TextModifier

Available on Widget, provided by the TextExtension extension

no setter
h1 TextModifier

Available on Widget, provided by the TextExtension extension

no setter
h2 TextModifier

Available on Widget, provided by the TextExtension extension

no setter
h3 TextModifier

Available on Widget, provided by the TextExtension extension

no setter
h4 TextModifier

Available on Widget, provided by the TextExtension extension

no setter
hashCode int
The hash code for this object.
no setterinherited
headingCheckboxTheme CheckboxThemeData?
Overrides theme of the checkbox that is displayed in the leftmost corner of the heading (should checkboxes be enabled)
final
headingRowColor MaterialStateProperty<Color?>?
The background color for the heading row.
finalinherited
headingRowDecoration BoxDecoration?
Overrides default BoxDecoration(bottom border) applied to heading row. When both headerRowColor and this porperty are provided:
final
headingRowHeight double?
The height of the heading row.
finalinherited
headingTextStyle TextStyle?
The text style for the heading row.
finalinherited
horizontalMargin double?
The horizontal margin between the edges of the table and the content in the first and last cells of each row.
finalinherited
horizontalScrollController ScrollController?
Exposes scroll controller of the SingleChildScrollView that makes data rows horizontally scrollable
final
ih Widget

Available on Widget, provided by the XWidgetArcane extension

no setter
inlineCode TextModifier

Available on Widget, provided by the TextExtension extension

no setter
intrinsicHeight Widget

Available on Widget, provided by the XWidget extension

no setter
intrinsicSize Widget

Available on Widget, provided by the XWidget extension

no setter
intrinsicWidth Widget

Available on Widget, provided by the XWidget extension

no setter
isHorizontalScrollBarVisible bool?
Determines whether the horizontal scroll bar is visible, for iOS takes value from scrollbarTheme when null
final
isVerticalScrollBarVisible bool?
Determines whether the vertical scroll bar is visible, for iOS takes value from scrollbarTheme when null
final
italic TextModifier

Available on Widget, provided by the TextExtension extension

no setter
iw Widget

Available on Widget, provided by the XWidgetArcane extension

no setter
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
large TextModifier

Available on Widget, provided by the TextExtension extension

no setter
lead TextModifier

Available on Widget, provided by the TextExtension extension

no setter
li TextModifier

Available on Widget, provided by the TextExtension extension

no setter
light TextModifier

Available on Widget, provided by the TextExtension extension

no setter
lmRatio double
Determines ratio of Large column's width to Medium column's width. I.e. 2.0 means that Large column is twice wider than Medium column.
final
medium TextModifier

Available on Widget, provided by the TextExtension extension

no setter
minWidth double?
If set, the table will stop shrinking below the threshold and provide horizontal scrolling. Useful for the cases with narrow screens (e.g. portrait phone orientation) and lots of columns (that get messed with little space)
final
modify TextModifier

Available on Widget, provided by the TextExtension extension

no setter
mono TextModifier

Available on Widget, provided by the TextExtension extension

no setter
muted TextModifier

Available on Widget, provided by the TextExtension extension

no setter
normal TextModifier

Available on Widget, provided by the TextExtension extension

no setter
onSelectAll ValueSetter<bool?>?
Invoked when the user selects or unselects every row, using the checkbox in the heading row.
finalinherited
p TextModifier

Available on Widget, provided by the TextExtension extension

no setter
primaryForeground TextModifier

Available on Widget, provided by the TextExtension extension

no setter
rows List<DataRow>
The data to show in each row (excluding the row that contains the column headings).
finalinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
safeArea Widget

Available on Widget, provided by the XWidget extension

no setter
sans TextModifier

Available on Widget, provided by the TextExtension extension

no setter
scrollable Widget

Available on Widget, provided by the XWidget extension

no setter
scrollableHorizontal Widget

Available on Widget, provided by the XWidget extension

no setter
scrollController ScrollController?
Exposes scroll controller of the SingleChildScrollView that makes data rows vertically scrollable
final
secondaryForeground TextModifier

Available on Widget, provided by the TextExtension extension

no setter
semiBold TextModifier

Available on Widget, provided by the TextExtension extension

no setter
showBottomBorder bool
Whether a border at the bottom of the table is displayed.
finalinherited
showCheckboxColumn bool
Whether the widget should display checkboxes for selectable rows.
finalinherited
showHeadingCheckBox bool
Whether to display heading checkbox or not if the checkbox column is present. Defaults to true. Also check DataTable.showCheckboxColumn for details on how to control the checkbox column visibility
final
singleLine TextModifier

Available on Widget, provided by the TextExtension extension

no setter
small TextModifier

Available on Widget, provided by the TextExtension extension

no setter
smRatio double
Determines ratio of Small column's width to Medium column's width. I.e. 0.5 means that Small column is twice narower than Medium column.
final
sortArrowAnimationDuration Duration
When changing sort direction an arrow icon in the header is rotated clockwise. The value defines the duration of the rotation animation. If not set, the default animation duration is 150 ms.
final
sortArrowBuilder Widget? Function(bool ascending, bool sorted)?
A builder for the sort arrow widget. Can be used in combination with sortArrowAlwaysVisible for a custom sort arrow behavior. If this is used sortArrowIcon, sortArrowAnimationDuration will be ignored.
final
sortArrowIcon IconData
Icon to be displayed when sorting is applied to a column. If not set, the default icon is Icons.arrow_upward. When set always overrides/preceeds default arrow icons.
final
sortAscending bool
Whether the column mentioned in sortColumnIndex, if any, is sorted in ascending order.
finalinherited
sortColumnIndex int?
The current primary sort key's column.
finalinherited
textCenter TextModifier

Available on Widget, provided by the TextExtension extension

no setter
textEnd TextModifier

Available on Widget, provided by the TextExtension extension

no setter
textJustify TextModifier

Available on Widget, provided by the TextExtension extension

no setter
textLarge TextModifier

Available on Widget, provided by the TextExtension extension

no setter
textLeft TextModifier

Available on Widget, provided by the TextExtension extension

no setter
textMuted TextModifier

Available on Widget, provided by the TextExtension extension

no setter
textRight TextModifier

Available on Widget, provided by the TextExtension extension

no setter
textSmall TextModifier

Available on Widget, provided by the TextExtension extension

no setter
textStart TextModifier

Available on Widget, provided by the TextExtension extension

no setter
thin TextModifier

Available on Widget, provided by the TextExtension extension

no setter
underline TextModifier

Available on Widget, provided by the TextExtension extension

no setter
x2Large TextModifier

Available on Widget, provided by the TextExtension extension

no setter
x3Large TextModifier

Available on Widget, provided by the TextExtension extension

no setter
x4Large TextModifier

Available on Widget, provided by the TextExtension extension

no setter
x5Large TextModifier

Available on Widget, provided by the TextExtension extension

no setter
x6Large TextModifier

Available on Widget, provided by the TextExtension extension

no setter
x7Large TextModifier

Available on Widget, provided by the TextExtension extension

no setter
x8Large TextModifier

Available on Widget, provided by the TextExtension extension

no setter
x9Large TextModifier

Available on Widget, provided by the TextExtension extension

no setter
xLarge TextModifier

Available on Widget, provided by the TextExtension extension

no setter
xSmall TextModifier

Available on Widget, provided by the TextExtension extension

no setter

Methods

animate({Key? key, List<Effect>? effects, AnimateCallback? onInit, AnimateCallback? onPlay, AnimateCallback? onComplete, bool? autoPlay, Duration? delay, AnimationController? controller, Adapter? adapter, double? target, double? value}) Animate

Available on Widget, provided by the AnimateWidgetExtensions extension

Wraps the target Widget in an Animate instance, and returns the instance for chaining calls. Ex. myWidget.animate() is equivalent to Animate(child: myWidget).
asSkeleton({bool enabled = true, bool leaf = false, Widget? replacement, bool unite = false, AsyncSnapshot? snapshot}) Widget

Available on Widget, provided by the SkeletonExtension extension

asSkeletonSliver({bool enabled = true}) Widget

Available on Widget, provided by the SkeletonExtension extension

build(BuildContext context) Widget
Describes the part of the user interface represented by this widget.
override
center({Key? key}) Widget

Available on Widget, provided by the WidgetExtension extension

clip({Clip clipBehavior = Clip.hardEdge}) Widget

Available on Widget, provided by the WidgetExtension extension

clipOval({Clip clipBehavior = Clip.antiAlias}) Widget

Available on Widget, provided by the WidgetExtension extension

clipPath({Clip clipBehavior = Clip.antiAlias, required CustomClipper<Path> clipper}) Widget

Available on Widget, provided by the WidgetExtension extension

clipRRect({BorderRadiusGeometry borderRadius = BorderRadius.zero, Clip clipBehavior = Clip.antiAlias}) Widget

Available on Widget, provided by the WidgetExtension extension

constrained({double? minWidth, double? maxWidth, double? minHeight, double? maxHeight, double? width, double? height}) Widget

Available on Widget, provided by the WidgetExtension extension

createElement() StatelessElement
Creates a StatelessElement to manage this widget's location in the tree.
inherited
debugContainer([Color color = Colors.red]) Widget

Available on Widget, provided by the DebugContainer extension

debugDescribeChildren() List<DiagnosticsNode>
Returns a list of DiagnosticsNode objects describing this node's children.
inherited
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node.
inherited
excludeSkeleton({bool exclude = true}) Widget

Available on Widget, provided by the SkeletonExtension extension

expanded({int flex = 1}) Widget

Available on Widget, provided by the WidgetExtension extension

getMinMaxRowHeight(DataTableThemeData dataTableTheme) → (double, double)
iconDestructiveForeground() Widget

Available on Widget, provided by the IconExtension extension

iconLarge() Widget

Available on Widget, provided by the IconExtension extension

iconMedium() Widget

Available on Widget, provided by the IconExtension extension

iconMutedForeground() Widget

Available on Widget, provided by the IconExtension extension

iconPrimary() Widget

Available on Widget, provided by the IconExtension extension

iconPrimaryForeground() Widget

Available on Widget, provided by the IconExtension extension

iconSecondary() Widget

Available on Widget, provided by the IconExtension extension

iconSecondaryForeground() Widget

Available on Widget, provided by the IconExtension extension

iconSmall() Widget

Available on Widget, provided by the IconExtension extension

iconX2Large() Widget

Available on Widget, provided by the IconExtension extension

iconX2Small() Widget

Available on Widget, provided by the IconExtension extension

iconX3Large() Widget

Available on Widget, provided by the IconExtension extension

iconX3Small() Widget

Available on Widget, provided by the IconExtension extension

iconX4Large() Widget

Available on Widget, provided by the IconExtension extension

iconX4Small() Widget

Available on Widget, provided by the IconExtension extension

iconXLarge() Widget

Available on Widget, provided by the IconExtension extension

iconXSmall() Widget

Available on Widget, provided by the IconExtension extension

ignoreSkeleton() Widget

Available on Widget, provided by the SkeletonExtension extension

intrinsic({double? stepWidth, double? stepHeight}) Widget

Available on Widget, provided by the WidgetExtension extension

intrinsicHeight() Widget

Available on Widget, provided by the WidgetExtension extension

intrinsicWidth({double? stepWidth, double? stepHeight}) Widget

Available on Widget, provided by the WidgetExtension extension

isSliver(BuildContext context) bool

Available on Widget, provided by the XSliverWidget extension

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
onDoublePressed(VoidCallback action, {HitTestBehavior? behavior, Set<PointerDeviceKind>? supportedDevices}) Widget

Available on Widget, provided by the XOnGestureWidget extension

Adds a handler for double press/tap gestures.
onHover(void action(bool hovering)) Widget

Available on Widget, provided by the XOnGestureWidget extension

Adds a handler for hover events.
onLongPressed(VoidCallback action, {HitTestBehavior? behavior, Set<PointerDeviceKind>? supportedDevices}) Widget

Available on Widget, provided by the XOnGestureWidget extension

Adds a handler for long press gestures with the primary button.
onLongSecondaryPressed(VoidCallback action, {HitTestBehavior? behavior, Set<PointerDeviceKind>? supportedDevices}) Widget

Available on Widget, provided by the XOnGestureWidget extension

Adds a handler for long press gestures with the secondary button.
onLongTertiaryPressed(VoidCallback action, {HitTestBehavior? behavior, Set<PointerDeviceKind>? supportedDevices}) Widget

Available on Widget, provided by the XOnGestureWidget extension

Adds a handler for long press gestures with the tertiary button.
onPressed(VoidCallback action, {HitTestBehavior? behavior, Set<PointerDeviceKind>? supportedDevices}) Widget

Available on Widget, provided by the XOnGestureWidget extension

Adds a handler for primary press/tap gestures (equivalent to onTap).
onSecondaryPressed(VoidCallback action, {HitTestBehavior? behavior, Set<PointerDeviceKind>? supportedDevices}) Widget

Available on Widget, provided by the XOnGestureWidget extension

Adds a handler for secondary press gestures (equivalent to right-click).
onTertiaryPressed(VoidCallback action, {HitTestBehavior? behavior, Set<PointerDeviceKind>? supportedDevices}) Widget

Available on Widget, provided by the XOnGestureWidget extension

Adds a handler for tertiary press gestures (equivalent to middle-click).
pad(double all) Widget

Available on Widget, provided by the XWidget extension

padBottom(double value) Widget

Available on Widget, provided by the XWidget extension

padLeft(double value) Widget

Available on Widget, provided by the XWidget extension

padOnly({double left = 0, double top = 0, double right = 0, double bottom = 0}) Widget

Available on Widget, provided by the XWidget extension

padRight(double value) Widget

Available on Widget, provided by the XWidget extension

padTop(double value) Widget

Available on Widget, provided by the XWidget extension

positioned({Key? key, double? left, double? top, double? right, double? bottom}) Widget

Available on Widget, provided by the WidgetExtension extension

shadeEdge(double radius) Widget

Available on Widget, provided by the XWidgetEdge extension

shadeFrost(double value) Widget

Available on Widget, provided by the XWidgetFrost extension

shadeInvert() Widget

Available on Widget, provided by the XWidgetInvert extension

shadePixelate(double radius) Widget

Available on Widget, provided by the XWidgetPixelate extension

shadePixelateBlur({int samples = 4, double pixelSize = 8, double radius = 2}) Widget

Available on Widget, provided by the XWidgetPixelateBlur extension

shadeRGB({double radius = 5, double spin = 1}) Widget

Available on Widget, provided by the XWidgetRGB extension

shadeWarp({double amplitude = 1, double frequency = 1, double z = 1, int octaves = 2}) Widget

Available on Widget, provided by the XWidgetWarp extension

shadeWarpAnimation({double amplitude = 1, double frequency = 1, double z = 1, double zSpeed = 1, int octaves = 2}) Widget

Available on Widget, provided by the XWidgetWarp extension

shimmer({bool loading = true}) Widget

Available on Widget, provided by the XWidgetArcane extension

sized({double? width, double? height}) Widget

Available on Widget, provided by the WidgetExtension extension

sized({double? width, double? height}) Widget

Available on Widget, provided by the XWidget extension

then(InlineSpan span) Widget

Available on Widget, provided by the TextExtension extension

thenButton({required VoidCallback onPressed, required Widget child}) Widget

Available on Widget, provided by the TextExtension extension

thenInlineCode(String text) Widget

Available on Widget, provided by the TextExtension extension

thenText(String text) Widget

Available on Widget, provided by the TextExtension extension

toBox(BuildContext context, {bool softWarn = true}) Widget

Available on Widget, provided by the XSliverWidget extension

toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep.
inherited
toSliver(BuildContext context, {bool fillRemaining = false, bool softWarn = true}) Widget

Available on Widget, provided by the XSliverWidget extension

toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) String
A string representation of this object.
inherited
toStringDeep({String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) String
Returns a string representation of this node and its descendants.
inherited
toStringShallow({String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) String
Returns a one-line detailed description of the object.
inherited
toStringShort() String
A short, textual description of this widget.
inherited
transform({Key? key, required Matrix4 transform}) Widget

Available on Widget, provided by the WidgetExtension extension

withAlign(AlignmentGeometry alignment) Widget

Available on Widget, provided by the WidgetExtension extension

withMargin({double? top, double? bottom, double? left, double? right, double? horizontal, double? vertical, double? all}) Widget

Available on Widget, provided by the WidgetExtension extension

withOpacity(double opacity) Widget

Available on Widget, provided by the WidgetExtension extension

withPadding({double? top, double? bottom, double? left, double? right, double? horizontal, double? vertical, double? all, EdgeInsetsGeometry? padding}) Widget

Available on Widget, provided by the WidgetExtension extension

withTooltip(String tooltip) Widget

Available on Widget, provided by the XWidgetArcane extension

Operators

operator ==(Object other) bool
The equality operator.
inherited