pub struct DataTable {Show 23 fields
pub key: Option<KeyRef>,
pub columns: Vec<DataColumn>,
pub sort_column_index: Option<usize>,
pub sort_ascending: bool,
pub sort_icon_builder: Option<DataTableSortIconBuilder>,
pub on_select_all: Option<ValueChanged<Option<bool>>>,
pub decoration: Option<DecorationRef>,
pub data_row_color: Option<WidgetStatePropertyRef<Option<Color>>>,
pub data_row_min_height: Option<f64>,
pub data_row_max_height: Option<f64>,
pub data_text_style: Option<TextStyle>,
pub heading_row_color: Option<WidgetStatePropertyRef<Option<Color>>>,
pub heading_row_height: Option<f64>,
pub heading_text_style: Option<TextStyle>,
pub horizontal_margin: Option<f64>,
pub column_spacing: Option<f64>,
pub show_checkbox_column: bool,
pub rows: Vec<DataRow>,
pub divider_thickness: Option<f64>,
pub show_bottom_border: bool,
pub checkbox_horizontal_margin: Option<f64>,
pub border: Option<TableBorder>,
pub clip_behavior: Clip,
/* private fields */
}Expand description
A Material Design data table.
Displaying data in a table is expected to be a common operation. For example, a list of users, with each user having a name, an age, and so on.
If the on_select_changed of any row is set, a checkbox
column is shown first, and a DataRow with a null on_select_changed is disabled.
The DataTable widget does not scroll on its own: if the table might be too large for its
parent, wrap it in a scrollable. A DataTable must have a Material ancestor if any of
its columns or rows are interactive.
The width of each column is determined by the algorithm in Table: by default, a column
that is the only non-numeric column gets an IntrinsicColumnWidth with a flex of 1, and
every other column an IntrinsicColumnWidth without one, unless the DataColumn gives a
column_width.
See also:
PaginatedDataTable, which shows part of the data in a data table and provides controls for paging through the remainder of the data.TableRowInkWell, a widget used to provide ink to a table row.
Fields§
§key: Option<KeyRef>§columns: Vec<DataColumn>The configuration and labels for the columns in the table.
sort_column_index: Option<usize>The current primary sort key’s column.
If non-null, indicates that the indicated column is the column by which the data is
sorted. The number must correspond to the index of the relevant column in [columns].
Setting this will cause the relevant column to have a sort indicator displayed.
When this is null, it implies that the table’s sort order does not correspond to any of the columns.
The direction of the sort is specified using sort_ascending.
sort_ascending: boolWhether the column mentioned in sort_column_index, if any,
is sorted in ascending order.
If true, the order is ascending (meaning the rows with the smallest values for the current sort column are first in the table).
If false, the order is descending (meaning the rows with the smallest values for the current sort column are last in the table).
Ascending order is represented by an upwards-facing arrow.
sort_icon_builder: Option<DataTableSortIconBuilder>Overrides the default sort indicator (an arrow) shown in a sortable column’s heading.
If null, the default arrow is used. Otherwise it is called with whether the column is sorted and whether it is sorted ascending.
on_select_all: Option<ValueChanged<Option<bool>>>Invoked when the user selects or unselects every row, using the checkbox in the heading row.
If this is null, then the DataRow::on_select_changed callback of every row in the
table is invoked appropriately instead.
To control whether a particular row is selectable or not, see
DataRow::on_select_changed. This callback is only relevant if any row is selectable.
decoration: Option<DecorationRef>The background and border decoration for the table.
data_row_color: Option<WidgetStatePropertyRef<Option<Color>>>The background color for the data rows.
The effective background color can be made to depend on the WidgetState state, i.e. if
the row is selected, pressed, hovered, focused, disabled or enabled. The color is painted
as an overlay to the row. To make sure that the row’s InkWell is visible (when
pressed, hovered and focused), it is recommended to use a translucent color.
If DataRow::color is non-null for a row, that color is used for that row instead.
data_row_min_height: Option<f64>The minimum height of each row (excluding the row that contains column headings).
This value is optional and defaults to K_MIN_INTERACTIVE_DIMENSION if not specified.
data_row_max_height: Option<f64>The maximum height of each row (excluding the row that contains column headings).
This value is optional and defaults to K_MIN_INTERACTIVE_DIMENSION if not specified.
data_text_style: Option<TextStyle>The text style for data rows.
By default, the text style is TextTheme::body_medium.
heading_row_color: Option<WidgetStatePropertyRef<Option<Color>>>The background color for the heading row.
The effective background color can be made to depend on the WidgetState state, i.e. if
the row is pressed, hovered, focused when sorted. The color is painted as an overlay to
the row.
heading_row_height: Option<f64>The height of the heading row.
This value is optional and defaults to 56.0 if not specified.
heading_text_style: Option<TextStyle>The text style for the heading row.
By default, the text style is TextTheme::title_small.
horizontal_margin: Option<f64>The horizontal margin between the edges of the table and the content in the first and last cells of each row.
When a checkbox is displayed, it is also the margin between the checkbox the content in the first data column.
This value defaults to 24.0 to adhere to the Material Design specifications.
If checkbox_horizontal_margin is null, then
horizontal_margin is also the margin between the edge of the
table and the checkbox, as well as the margin between the checkbox and the content in the
first data column.
column_spacing: Option<f64>The horizontal margin between the contents of each data column.
This value defaults to 56.0 to adhere to the Material Design specifications.
show_checkbox_column: boolWhether the widget should display checkboxes for selectable rows.
If true, a Checkbox will be placed at the beginning of each row that is selectable.
However, if DataRow::on_select_changed is not set for any row, checkboxes will not be
placed, even if this value is true.
If false, all rows will not display a Checkbox.
rows: Vec<DataRow>The data to show in each row (excluding the row that contains the column headings).
The list may be empty.
divider_thickness: Option<f64>The thickness of the divider between rows.
This value is optional and defaults to 1.0 if not specified.
show_bottom_border: boolWhether a border at the bottom of the table is displayed.
By default, a border is not shown at the bottom to allow for a border around the table
defined by decoration.
checkbox_horizontal_margin: Option<f64>Horizontal margin around the checkbox, if it is displayed.
If null, then horizontal_margin is used as the margin
between the edge of the table and the checkbox, as well as the margin between the
checkbox and the content in the first data column. This value defaults to 24.0.
border: Option<TableBorder>The style to use when painting the boundary and interior divisions of the table.
clip_behavior: Clip{@macro flutter.material.Material.clipBehavior}
This can be used to clip the content within the border of the DataTable.
Defaults to Clip::None.
Implementations§
Source§impl DataTable
impl DataTable
Sourcepub fn new(columns: Vec<DataColumn>, rows: Vec<DataRow>) -> DataTable
pub fn new(columns: Vec<DataColumn>, rows: Vec<DataRow>) -> DataTable
Creates a widget describing a data table; Dart’s optional named arguments are the setters.
The columns argument must be a list of as many DataColumn objects
as the table is to have columns, ignoring the leading checkbox column which may be
omitted. The rows argument must be a list of DataRow objects to be
shown, each with a DataRow::cells list of the same length as columns.
Sourcepub fn sort_column_index(self, sort_column_index: usize) -> DataTable
pub fn sort_column_index(self, sort_column_index: usize) -> DataTable
Dart DataTable(sortColumnIndex:).
Sourcepub fn sort_ascending(self, sort_ascending: bool) -> DataTable
pub fn sort_ascending(self, sort_ascending: bool) -> DataTable
Dart DataTable(sortAscending:).
Sourcepub fn sort_icon_builder(
self,
sort_icon_builder: impl Fn(&mut App, BuildContext, bool, bool) -> WidgetRef + 'static,
) -> DataTable
pub fn sort_icon_builder( self, sort_icon_builder: impl Fn(&mut App, BuildContext, bool, bool) -> WidgetRef + 'static, ) -> DataTable
Dart DataTable(sortIconBuilder:).
Sourcepub fn on_select_all(
self,
on_select_all: impl Fn(&mut App, Option<bool>) + 'static,
) -> DataTable
pub fn on_select_all( self, on_select_all: impl Fn(&mut App, Option<bool>) + 'static, ) -> DataTable
Dart DataTable(onSelectAll:).
Sourcepub fn decoration(self, decoration: impl Into<DecorationRef>) -> DataTable
pub fn decoration(self, decoration: impl Into<DecorationRef>) -> DataTable
Dart DataTable(decoration:).
Sourcepub fn data_row_color(
self,
data_row_color: WidgetStatePropertyRef<Option<Color>>,
) -> DataTable
pub fn data_row_color( self, data_row_color: WidgetStatePropertyRef<Option<Color>>, ) -> DataTable
Dart DataTable(dataRowColor:).
Sourcepub fn data_row_height(self, data_row_height: f64) -> DataTable
👎Deprecated: Migrate to use data_row_min_height and data_row_max_height instead. This feature was deprecated after v3.7.0-5.0.pre.
pub fn data_row_height(self, data_row_height: f64) -> DataTable
Migrate to use data_row_min_height and data_row_max_height instead. This feature was deprecated after v3.7.0-5.0.pre.
Dart’s deprecated DataTable(dataRowHeight:): it sets
data_row_min_height and
data_row_max_height to one value.
Dart asserts that the argument is not given with either of them; a fluent chain has no one call to compare, so a later setter replaces what an earlier one wrote.
Sourcepub fn data_row_min_height(self, data_row_min_height: f64) -> DataTable
pub fn data_row_min_height(self, data_row_min_height: f64) -> DataTable
Dart DataTable(dataRowMinHeight:).
Sourcepub fn data_row_max_height(self, data_row_max_height: f64) -> DataTable
pub fn data_row_max_height(self, data_row_max_height: f64) -> DataTable
Dart DataTable(dataRowMaxHeight:).
Sourcepub fn data_text_style(self, data_text_style: TextStyle) -> DataTable
pub fn data_text_style(self, data_text_style: TextStyle) -> DataTable
Dart DataTable(dataTextStyle:).
Sourcepub fn heading_row_color(
self,
heading_row_color: WidgetStatePropertyRef<Option<Color>>,
) -> DataTable
pub fn heading_row_color( self, heading_row_color: WidgetStatePropertyRef<Option<Color>>, ) -> DataTable
Dart DataTable(headingRowColor:).
Sourcepub fn heading_row_height(self, heading_row_height: f64) -> DataTable
pub fn heading_row_height(self, heading_row_height: f64) -> DataTable
Dart DataTable(headingRowHeight:).
Sourcepub fn heading_text_style(self, heading_text_style: TextStyle) -> DataTable
pub fn heading_text_style(self, heading_text_style: TextStyle) -> DataTable
Dart DataTable(headingTextStyle:).
Sourcepub fn horizontal_margin(self, horizontal_margin: f64) -> DataTable
pub fn horizontal_margin(self, horizontal_margin: f64) -> DataTable
Dart DataTable(horizontalMargin:).
Sourcepub fn column_spacing(self, column_spacing: f64) -> DataTable
pub fn column_spacing(self, column_spacing: f64) -> DataTable
Dart DataTable(columnSpacing:).
Sourcepub fn show_checkbox_column(self, show_checkbox_column: bool) -> DataTable
pub fn show_checkbox_column(self, show_checkbox_column: bool) -> DataTable
Dart DataTable(showCheckboxColumn:).
Sourcepub fn show_bottom_border(self, show_bottom_border: bool) -> DataTable
pub fn show_bottom_border(self, show_bottom_border: bool) -> DataTable
Dart DataTable(showBottomBorder:).
Sourcepub fn divider_thickness(self, divider_thickness: f64) -> DataTable
pub fn divider_thickness(self, divider_thickness: f64) -> DataTable
Dart DataTable(dividerThickness:).
Sourcepub fn checkbox_horizontal_margin(
self,
checkbox_horizontal_margin: f64,
) -> DataTable
pub fn checkbox_horizontal_margin( self, checkbox_horizontal_margin: f64, ) -> DataTable
Dart DataTable(checkboxHorizontalMargin:).
Sourcepub fn border(self, border: TableBorder) -> DataTable
pub fn border(self, border: TableBorder) -> DataTable
Dart DataTable(border:).
Sourcepub fn clip_behavior(self, clip_behavior: Clip) -> DataTable
pub fn clip_behavior(self, clip_behavior: Clip) -> DataTable
Dart DataTable(clipBehavior:).
Sourcepub fn data_row_height_value(&self) -> Option<f64>
👎Deprecated: Migrate to use data_row_min_height and data_row_max_height instead. This feature was deprecated after v3.7.0-5.0.pre.
pub fn data_row_height_value(&self) -> Option<f64>
Migrate to use data_row_min_height and data_row_max_height instead. This feature was deprecated after v3.7.0-5.0.pre.
Dart’s deprecated dataRowHeight getter: the row height, if the minimum and the maximum
are the same.
Trait Implementations§
Source§impl StatelessWidget for DataTable
impl StatelessWidget for DataTable
Source§fn debug_check_constructor(&self)
fn debug_check_constructor(&self)
Source§fn build(&self, app: &mut App, context: BuildContext) -> WidgetRef
fn build(&self, app: &mut App, context: BuildContext) -> WidgetRef
Source§fn debug_fill_properties(
&self,
_app: &App,
properties: &mut DiagnosticPropertiesBuilder,
)
fn debug_fill_properties( &self, _app: &App, properties: &mut DiagnosticPropertiesBuilder, )
debugFillProperties: the properties a dump shows for this widget, in Dart’s
order. Dart’s Widget base only sets the dense tree style, which the framework does.Source§fn as_preferred_size_widget(
&self,
) -> Option<&(dyn PreferredSizeWidget + 'static)>
fn as_preferred_size_widget( &self, ) -> Option<&(dyn PreferredSizeWidget + 'static)>
this is PreferredSizeWidget: a widget that implements PreferredSizeWidget
answers with itself, which is what a parent asking an erased child for its preferred
size reads.Auto Trait Implementations§
impl !RefUnwindSafe for DataTable
impl !Send for DataTable
impl !Sync for DataTable
impl !UnwindSafe for DataTable
impl Forget for DataTable
impl Freeze for DataTablewhere
*const RcInner<dyn Key> is !null: Freeze,
PhantomData<RcInner<dyn Key>>: Freeze,
*const u8 is !null: Freeze,
PhantomData<DataColumn>: Freeze,
*const RcInner<dyn Fn(&mut App, AnyElement, bool, bool) -> Rc<dyn Widget>> is !null: Freeze,
PhantomData<RcInner<dyn Fn(&mut App, AnyElement, bool, bool) -> Rc<dyn Widget>>>: Freeze,
*const RcInner<dyn Fn(&mut App, Option<bool>)> is !null: Freeze,
PhantomData<RcInner<dyn Fn(&mut App, Option<bool>)>>: Freeze,
*const RcInner<dyn Decoration> is !null: Freeze,
PhantomData<RcInner<dyn Decoration>>: Freeze,
*const RcInner<dyn WidgetStateProperty<Option<Color>>> is !null: Freeze,
PhantomData<RcInner<dyn WidgetStateProperty<Option<Color>>>>: Freeze,
&'static dyn ColorExtension: Freeze,
*const RcInner<dyn ColorExtension> is !null: Freeze,
PhantomData<RcInner<dyn ColorExtension>>: Freeze,
PhantomData<u8>: Freeze,
PhantomData<String>: Freeze,
*const RcInner<Paint> is !null: Freeze,
PhantomData<RcInner<Paint>>: Freeze,
PhantomData<Shadow>: Freeze,
PhantomData<FontFeature>: Freeze,
PhantomData<FontVariation>: Freeze,
PhantomData<DataRow>: Freeze,
impl Move for DataTable
impl Unpin for DataTablewhere
Rc<dyn Key>: Unpin,
*const u8 is !null: Unpin,
Rc<dyn Widget>: Unpin,
Rc<dyn TableColumnWidth>: Unpin,
Rc<dyn Fn(&mut App, i32, bool)>: Unpin,
Rc<dyn WidgetStateProperty<Option<Rc<dyn MouseCursor>>>>: Unpin,
Rc<dyn Fn(&mut App, AnyElement, bool, bool) -> Rc<dyn Widget>>: Unpin,
Rc<dyn Fn(&mut App, Option<bool>)>: Unpin,
Rc<dyn Decoration>: Unpin,
Rc<dyn WidgetStateProperty<Option<Color>>>: Unpin,
&'static dyn ColorExtension: Unpin,
Rc<dyn ColorExtension>: Unpin,
Rc<Paint>: Unpin,
Rc<dyn LocalKey>: Unpin,
Rc<dyn Fn(&mut App)>: Unpin,
NonZero<u32>: Unpin,
*const (): Unpin,
Rc<dyn Fn(&mut App, bool)>: Unpin,
Rc<dyn Fn(&mut App, TapDownDetails)>: Unpin,
impl UnsafeUnpin for DataTablewhere
*const RcInner<dyn Key> is !null: UnsafeUnpin,
PhantomData<RcInner<dyn Key>>: UnsafeUnpin,
*const u8 is !null: UnsafeUnpin,
PhantomData<DataColumn>: UnsafeUnpin,
*const RcInner<dyn Fn(&mut App, AnyElement, bool, bool) -> Rc<dyn Widget>> is !null: UnsafeUnpin,
PhantomData<RcInner<dyn Fn(&mut App, AnyElement, bool, bool) -> Rc<dyn Widget>>>: UnsafeUnpin,
*const RcInner<dyn Fn(&mut App, Option<bool>)> is !null: UnsafeUnpin,
PhantomData<RcInner<dyn Fn(&mut App, Option<bool>)>>: UnsafeUnpin,
*const RcInner<dyn Decoration> is !null: UnsafeUnpin,
PhantomData<RcInner<dyn Decoration>>: UnsafeUnpin,
*const RcInner<dyn WidgetStateProperty<Option<Color>>> is !null: UnsafeUnpin,
PhantomData<RcInner<dyn WidgetStateProperty<Option<Color>>>>: UnsafeUnpin,
&'static dyn ColorExtension: UnsafeUnpin,
*const RcInner<dyn ColorExtension> is !null: UnsafeUnpin,
PhantomData<RcInner<dyn ColorExtension>>: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
PhantomData<String>: UnsafeUnpin,
*const RcInner<Paint> is !null: UnsafeUnpin,
PhantomData<RcInner<Paint>>: UnsafeUnpin,
PhantomData<Shadow>: UnsafeUnpin,
PhantomData<FontFeature>: UnsafeUnpin,
PhantomData<FontVariation>: UnsafeUnpin,
PhantomData<DataRow>: UnsafeUnpin,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<W> IntoWidget<StatelessKind> for Wwhere
W: StatelessWidget,
impl<W> IntoWidget<StatelessKind> for Wwhere
W: StatelessWidget,
Source§fn into_widget(self) -> Rc<dyn Widget>
fn into_widget(self) -> Rc<dyn Widget>
creation_location.