fitgrid_table library
A Flutter data grid that measures your content instead of making you guess column widths, and paints cells instead of building a widget for each one.
Start with FitGrid and FitGridColumn. Column widths come from FitGridColumnWidth, visuals from FitGridThemeData, and programmatic control from FitGridController.
Cells are painted, not built, which means find.text will not see them in
widget tests. Use package:fitgrid_table/testing.dart for that — it has no
dependency on the test framework, so it costs applications nothing.
Classes
-
FitGrid<
T> - A data grid that measures its columns and paints its cells.
- FitGridActivateIntent
- Opens an editor on the focused cell, or fires the tap callbacks when the cell is not editable — the keyboard equivalent of activating it.
-
FitGridAsyncDataSource<
T> - A FitGridDataSource that fetches fixed-size pages through a callback and caches the ones it has.
- FitGridAutoWidth
- Content-measured width. See FitGridColumnWidth.auto.
-
FitGridBarVisual<
T> - FitGridCellChange
- One cell's value, before and after an edit.
-
FitGridCellEdit<
T> - One value written to one cell, by anything other than the user typing into an editor — a paste, a Delete over a range, a fill-handle drag.
- FitGridCellRange
- A rectangle of cells: every row between two rows and every column between two columns, inclusive.
- FitGridCellRangeState
-
The selected rectangle of cells, when
FitGrid.cellSelectionis on. -
FitGridCellVisual<
T> - A small chart painted into each cell of a column — a data bar, a progress track, a sparkline.
- FitGridClearCellsIntent
- Empties the editable cells of the selected range, or the focused cell.
-
FitGridColumn<
T> - One column of a FitGridColumn-driven grid.
-
FitGridColumnChooser<
T> - A button that opens a checklist of the grid's columns, for showing and hiding them.
- FitGridColumnFilter
- One column's filter, as data.
- FitGridColumnGroup
- A band in the header spanning several columns — "Q1" over January, February and March.
- FitGridColumnLayout
- The resolved horizontal geometry of a grid: which columns are visible, how wide each one is, where each one starts, and which of them are pinned to an edge instead of scrolling.
-
FitGridColumnState<
T> - Column order, visibility and user-applied widths.
- FitGridColumnWidth
- How a column decides how wide it wants to be.
- FitGridContentRowHeight
- Per-row measured height. See FitGridRowHeight.contentSized.
-
FitGridContextMenuTarget<
T> - Where a context menu was asked for.
-
FitGridController<
T> - The grid's state, in one place.
- FitGridCopyIntent
- Copies the selection — or the focused cell, when nothing is selected — to the clipboard.
-
FitGridDataSource<
T> - Rows the grid does not hold.
-
FitGridDataState<
T> - Rows, and the ordering applied to them.
- FitGridDetailState
-
Which rows have their detail panel open, when
FitGrid.detailBuilderis set. - FitGridDismissIntent
- Clears the selection, or closes an open editor.
-
FitGridDisplayRow<
T> - One line in the body: a data row, or a header standing over a group of them.
- FitGridEditHistory
- Edits the user has made, for undo and redo.
- FitGridEditingState
- Which cell, if any, is open for editing.
-
FitGridEditor<
T> - Makes a column editable, and says how.
-
FitGridEditorSession<
T> - Everything a custom editor needs to do its job.
- FitGridExportData
- The grid's contents, in the shape an exporter wants.
- FitGridExportRow
- What a row looks like to an exporter.
-
FitGridFilterSpec<
T> - How a column takes part in filtering: what kind of value it holds, and where that value comes from.
-
FitGridFilterState<
T> - The active search text and column filters.
- FitGridFitHeaderWidth
- Header-only measured width. See FitGridColumnWidth.fitHeader.
- FitGridFixedRowHeight
- Uniform row height. See FitGridRowHeight.fixed.
- FitGridFixedWidth
- Exact width. See FitGridColumnWidth.fixed.
- FitGridFlexWidth
- Proportional share of leftover width. See FitGridColumnWidth.flex.
- FitGridFocusState
- Which cell the keyboard is on.
- The aggregate row under the grid.
-
FitGridGroup<
T> - Groups rows by a key derived from each one.
-
FitGridGroupingState<
T> - How rows are grouped or nested, and which of the groups are open.
-
FitGridHeader<
T> - The pinned header row.
- FitGridJumpIntent
- Jumps the focus to an edge — Home, End, and their Ctrl variants.
- FitGridMeasuredRowMetrics
- Measured row heights. See FitGridRowMetrics.measured.
- FitGridMoveIntent
- Moves the focused cell by whole steps.
- FitGridMoveRowIntent
- Moves the focused row up or down, when rows are reorderable.
- FitGridPageIntent
- Moves the focus by a viewport of rows.
- FitGridPager
- The default pager strip below the grid.
- FitGridPageRequest
- What the grid asks a FitGridAsyncDataSource for.
-
FitGridPageResult<
T> - What the source hands back.
-
FitGridPageView<
T> - One page of a list, without copying it.
- FitGridPaginationState
- Which page of the rows is on screen, and how big a page is.
- FitGridPasteIntent
- Pastes tab-separated text from the clipboard into the editable cells at the selected range or the focused cell.
-
FitGridPivotDimension<
T> - Something to pivot by: a row heading, or a set of column headings.
- FitGridPivotResult
-
What fitGridPivot produces: rows and columns ready for a
FitGrid. - FitGridPivotRow
- One row of a pivot: its headings, and a number per generated column.
-
FitGridPivotValue<
T> - A number to put in the cells, and how to combine it.
-
FitGridProgressVisual<
T> - FitGridRedoIntent
- Reapplies the most recently undone edit.
- FitGridRowHeight
- How tall each row is.
- FitGridRowMetrics
- Where every row sits vertically, and how tall it is.
-
FitGridRowsView<
T> - The rows the grid is showing right now, however they are stored.
- FitGridSavedState
- Everything about a grid a user would expect it to remember: the column order, which columns are hidden or pinned, the widths they were dragged to, the sort, the filters, the search and the page.
- FitGridSelectAllIntent
- Selects every row.
- FitGridSelectionState
- Which rows are selected, and how many may be.
- FitGridSortKey
- One level of a sort: a column and which way it runs.
-
FitGridSparklineVisual<
T> - FitGridTheme
- Supplies a FitGridThemeData to the grids beneath it.
- FitGridThemeData
- Visual configuration for a grid.
- FitGridToggleSelectionIntent
- Toggles the focused row's membership of the selection.
-
FitGridTree<
T> - Turns flat rows into a tree.
- FitGridUndoIntent
- Reverts the most recent edit.
- FitGridUniformRowMetrics
- Uniform row heights. See FitGridRowMetrics.uniform.
Enums
- FitGridAggregation
- How a pivot reduces the rows in one cell to a number.
- FitGridAlignment
- Horizontal placement of a cell's content within its column.
- FitGridDensity
- Vertical rhythm. Scales row height and cell padding together.
- FitGridEditTrigger
- What opens an editor on a cell.
- FitGridFilterKind
- What kind of value a column filters on, which decides the operators the filter panel offers and how the typed text is read.
- FitGridFilterOperator
- How a column filter compares a cell to what the user typed.
- FitGridFreeze
- Which edge, if any, a column is pinned to while the body scrolls sideways.
- FitGridOverflow
- What a cell does when its text is wider than the column.
- FitGridSelectionMode
- How many rows the user may select by pointer or keyboard.
- FitGridSortDirection
- Sort state of a single column. Sorting is tri-state: the third tap on a header clears the sort rather than cycling back to ascending.
Constants
-
kFitGridShortcuts
→ const Map<
ShortcutActivator, Intent> - The default keyboard map.
Functions
-
buildFitGridExport<
T> ({required List< FitGridColumn< columns, required List<T> >T> rows, List<FitGridDisplayRow< ? display, Iterable<T> >int> ? only, bool includeHeaders = true}) → FitGridExportData - Builds export data from columns and rows.
-
fitGridColumnChooserItems<
T> (FitGridController< T> controller, {String showAllLabel = 'Show all'}) → List<Widget> - The checklist itself, as menu items, for hosts that want it inside a menu of their own.
-
fitGridFillSeries(
List< String> source, int count, {bool backwards = false}) → List<String> -
The values a fill-handle drag writes, continuing
sourceforcountcells. -
fitGridParseDelimited(
String text, {String delimiter = ','}) → List< List< String> > - Parses delimited text — what fitGridToDelimited writes, and what a spreadsheet puts on the clipboard — back into rows of cells.
-
fitGridPivot<
T> (List< T> source, {required List<FitGridPivotDimension< rows, FitGridPivotDimension<T> >T> ? columns, required List<FitGridPivotValue< values, bool columnTotals = true}) → FitGridPivotResultT> > -
Pivots
sourceinto summary rows. -
fitGridToCsv(
FitGridExportData data) → String - Shorthand for fitGridToDelimited with a comma.
-
fitGridToDelimited(
FitGridExportData data, {String delimiter = ',', String lineEnding = '\n', bool indentNesting = true}) → String - Writes export data as delimited text.
-
fitGridToTsv(
FitGridExportData data) → String - Shorthand for fitGridToDelimited with a tab — what the clipboard uses, and what pastes into a spreadsheet without an import dialog.
-
fitGridToXlsx(
FitGridExportData data, {String sheetName = 'Sheet1', bool detectNumbers = true, bool freezeHeader = true}) → Uint8List -
Writes export data as an Excel workbook (
.xlsx), returning its bytes. -
flattenGroups<
T> ({required List< T> rows, required List<FitGridGroup< groups, required bool isExpanded(Object key), int depth = 0, Object? parentKey}) → List<T> >FitGridDisplayRow< T> > - Flattens rows into display lines, expanding only what is open.
-
flattenTree<
T> ({required List< T> rows, required FitGridTree<T> tree, required bool isExpanded(Object key), required Object keyOf(T row)}) → List<FitGridDisplayRow< T> > - Flattens a hierarchy into display lines, descending only into open nodes.
-
insertDetails<
T> (List< FitGridDisplayRow< lines, bool isExpanded(T row)) → List<T> >FitGridDisplayRow< T> > -
Inserts a detail line after every data line whose row
isExpandedsays is open. -
showFitGridColumnDialog<
T> (BuildContext context, FitGridController< T> controller, {String title = 'Columns', String showAllLabel = 'Show all', String closeLabel = 'Done'}) → Future<void> - Shows the column checklist in a dialog. What the column menu's "Columns…" item opens, and usable on its own where a menu anchor is awkward — on a phone, say, where a dialog is the more natural surface.
-
showFitGridFilterDialog<
T> (BuildContext context, FitGridController< T> controller, String columnId) → Future<void> - Opens the filter editor for one column.
Typedefs
-
FitGridAggregate<
T> = String Function(List< T> rows) - Reduces the rows under a column to one string for the footer.
-
FitGridCellBuilder<
T> = Widget Function(BuildContext context, T row, int rowIndex) - Builds a real widget for one cell, instead of painted text.
-
FitGridCellCommit<
T> = void Function(T row, int rowIndex, String value) - Applies a committed edit.
-
FitGridCellIcon<
T> = IconData? Function(T row, int rowIndex) - Resolves a glyph to paint before a cell's text, or null for none.
-
FitGridCellIconColor<
T> = Color? Function(T row, int rowIndex) - Resolves the colour of that glyph, or null to follow the text.
-
FitGridCellStyle<
T> = TextStyle? Function(T row, int rowIndex) - Per-cell text style override, layered on top of the theme's cell style.
-
FitGridCellValidator<
T> = String? Function(T row, String value) - What a committed edit should do to a cell that failed validation.
-
FitGridCellValue<
T> = String Function(T row) - Resolves the painted text for one cell.
-
FitGridEditorBuilder<
T> = Widget Function(BuildContext context, FitGridEditorSession< T> session) - Builds a bespoke editor for a cell, in place of the default text field.
- FitGridPageLabel = String Function(int first, int last, int total)
- Formats the "1–25 of 1,000" label. Swap it out for another language, another numeral system, or a different phrasing entirely.
-
FitGridRowPredicate<
T> = bool Function(T row) - Whether a row passes a column's filter.