advanced library

The engine's pipeline, for code that runs it rather than uses it.

package:lattice_core/lattice_core.dart is the surface an application needs: a controller, columns, a data source, and the specs that describe what to show. This library adds the stages the controller drives - the sorter, the grouper, the aggregator, the flatteners - plus the few implementation types they hand back.

Reach for it when you are writing a LatticeDataSource of your own and want to run part of the pipeline locally, or an adapter for another toolkit. Everything here is lower level and shaped by what the engine needs rather than by what reads well at a call site; the everyday library deliberately does not export it, so that a published API is a promise about the things applications actually hold.

Classes

AggregateResult
Aggregate results for one group or for the whole grid, keyed by Aggregation.id.
Aggregation
Computes one aggregate over the values of one column.
AsyncDataSource<T>
Wraps an async callback as a data source.
CellAddress
A single cell, addressed by row index and column field.
CellDecoration
How a cell should be emphasised.
CellEdit<T>
One cell's value before and after an edit.
CellRange
A rectangular block of cells between two anchors, inclusive.
CellRule
Decides how one cell should look, given its value and its column's range.
ColorScaleRule
Tints the cell by where the value sits in the column's range.
ColumnLayout<T>
One laid-out column: its resolved width and its x position within its pane.
ColumnStats
Range of a column's values, so a rule can place one value against the rest.
ColumnViewState
One column's arrangement.
CompiledFilter
A Filter prepared to be run over many rows.
CsvExporter<T>
Writes rows as delimiter-separated text.
DataBarRule
Fills part of the cell in proportion to the value's place in the column.
DataGridRow<T>
DetailGridRow<T>
A panel opened under its row, for the fields a row has no room for.
DetailRowList<T>
A row list that interleaves open detail panels without materialising anything.
DistinctValues
The distinct values of one column, and whether there are more.
EditAction<T>
One step of undo: everything a single user action changed.
EditHistory<T>
A bounded undo/redo stack of EditActions.
EditResult<T>
The result of trying to commit an edit.
EditSession<T>
One in-flight cell edit.
ExportOptions
Shaping options shared by the text exporters.
FetchSignal
Tells a data source that the grid no longer wants the answer.
Filter
Common interface of FilterCondition and FilterGroup.
FilterCondition
A single field operator value test.
FilterGroup
Combines child filters with FilterJoin.and or FilterJoin.or.
FirstMatchRule
Applies the first rule that fires, in order.
Float64ListLike
Fixed-length FloatList backed by a plain List.
FloatList
Minimal growable double list, so the engine needs no dart:typed_data specialisation on the web and stays dependency-free.
GridColumn<T>
Describes one column of a grid.
GridController<T>
Owns every piece of grid state and the pipeline that turns it into rows.
GridLayout<T>
The three horizontal panes of a grid: the columns frozen to the leading edge, the scrolling middle, and the columns frozen to the trailing edge.
GridQuery
A complete description of what the grid wants to show.
GridResult<T>
The answer to a GridQuery.
GridRow<T>
A single renderable row.
GridViewState
Everything about how a grid is arranged, in a form that round-trips through storage or an HTTP backend.
GroupChildren<T>
What one group holds, fetched when the user opened it.
GroupedRowList<T>
A grouped row list that resolves positions arithmetically instead of materialising every row.
GroupExpansionState
Tracks which group paths are open.
GroupGridRow<T>
A collapsible group header row.
GroupKey
One level of a group's identity: which column, and which value.
GroupNode<T>
A node of the grouped row tree.
GroupSpec
One level of grouping.
HeaderBand
One cell of a stacked header row, spanning the columns it names.
HeaderBandLayout<T>
A band resolved against a laid-out pane: where to draw it, and how wide.
HeaderRow
One row of a stacked header, drawn above the column titles.
InMemoryDataSource<T>
Serves rows from a list already in memory.
LatticeDataSource<T>
Supplies rows for a GridQuery.
LazyDataRowList<T>
A read-only row list that materialises each DataGridRow on demand.
MergedRule
Merges every rule that fires, later ones winning on conflicts.
NestedRows<T>
The flat form of a nested model, from flattenNestedRows.
PasteRejection
Why one cell of a paste could not be written.
PasteResult
What a paste did, or would have done.
ReplayOutcome
What came of applying one EditAction.
RowMetrics
Maps between scroll offsets and row indices.
RowSlice<T>
A read-only window onto part of a row list.
RowUpdate<T>
One row to be written, as it was and as it should become.
RowWindow
The slice of rows a viewport can see.
SelectionModifiers
Modifier keys in effect when a selection gesture happened.
SelectionState
Holds and mutates the current selection.
SortSpec
One level of an ordering.
SourceCapabilities
What a data source can do, as the source itself declares it.
ThresholdRule
Applies a tone once the value passes a threshold.
TreeRowInfo
A row backed by one item of the data source. A row's place in a tree.
TreeSpec<T>
How the rows form a hierarchy.
ValueToneRule
Maps discrete values to tones, for status and severity columns.

Enums

AggregateType
Built-in aggregate functions.
CellTone
The meaning of a cell's emphasis, which an adapter maps to real colours.
ColumnAlign
Horizontal alignment of a cell's content.
ColumnFit
How leftover horizontal space is distributed.
ColumnPin
Which edge of the viewport a column is frozen to, if any.
ColumnType
Logical type of a column's values.
EditOutcome
Why an edit session ended.
FilterJoin
How the children of a FilterGroup combine.
FilterOperator
Comparison applied by a FilterCondition.
GridChange
What changed, so a listener can repaint only what depends on it.
NullsPosition
Where nulls land relative to real values.
SelectionCoverage
How much of the grid is selected, for a select-all control.
SelectionMode
What the user is allowed to select.
SortDirection

Mixins

GridChangeNotifier
The smallest useful observable: add a listener, get notified, dispose.

Extensions

FilterOperatorInput on FilterOperator
What a FilterOperator needs from the user before it means anything.

Constants

everyGridChange → const Set<GridChange>
Every kind of change, which is what a caller that does not say means.
filterBigIntKey → const String
Key a BigInt operand is written under in JSON.
filterDateKey → const String
Key a typed operand is written under in JSON.
latticeSchemaVersion → const int
The schema version this build writes.
latticeSchemaVersionKey → const String
Key the version is stored under. Short, because it appears in every document.

Functions

buildComparator<T>(List<SortSpec> sorts, Map<String, GridColumn<T>> columns) → Comparator<T>
Builds a Comparator for T that applies sorts in order, using each column's own GridColumn.comparator where one is defined.
buildGroups<T>(List<T> rows, List<GroupSpec> groups, Map<String, GridColumn<T>> columns, {List<Aggregation> aggregations = const [], int depth = 0, String parentPath = '', List<GroupKey> parentKeys = const []}) → List<GroupNode<T>>
Groups rows by groups, computing aggregations at every level.
coerceFilterOperand(Object? operand, ColumnType? type, {bool dateOnly = false}) → Object?
Coerces a filter operand to the type of the column it tests.
coerceValue(String text, ColumnType type) → Object?
Parses editor text back into the column's value type.
collectGroupPaths<T>(List<GroupNode<T>> nodes) → List<String>
Every group path in a tree.
collectTreePaths<T>({required List<T> rows, required TreeSpec<T> spec, required Object keyOf(T row)}) → List<String>
Every tree path in rows, for collapsing a tree whose branches the user has never opened.
combineValidators(List<ValueValidator> validators) → ValueValidator
Composes validators, reporting the first failure.
compareValues(Object? a, Object? b) → int
Compares two arbitrary cell values in a total, null-safe order.
compareValuesCaseInsensitive(Object? a, Object? b) → int
Case- and accent-insensitive variant of compareValues for text columns.
compareValuesFolded(Object? a, Object? b) → int
Compares values with case and accents folded away and no tiebreak, so that 'Apple', 'apple' and 'ápple' all compare equal.
compareValuesNatural(Object? a, Object? b) → int
Compares values the way a human reads embedded numbers, so that item2 sorts before item10.
compileCondition(FilterCondition condition, ColumnType? type) → CompiledFilter
Compiles one condition, coercing its operands to type when it is known.
computeAggregates<T>(List<T> rows, List<Aggregation> aggregations, Object? read(T row, String field)) → AggregateResult
Runs every aggregation in aggregations over rows.
computeColumnStats(Iterable<Object?> values) → ColumnStats
Computes ColumnStats for one column's values.
computeLayout<T>(List<GridColumn<T>> columns, {required double viewportWidth, Map<String, double> widthOverrides = const {}, ColumnFit fit = ColumnFit.none}) → GridLayout<T>
Resolves columns into a GridLayout for a viewport of viewportWidth.
cycleSort(List<SortSpec> sorts, String field, {bool additive = false}) → List<SortSpec>
Applies the three-state header-click cycle (unsorted -> ascending -> descending -> unsorted) to sorts.
decodeFilterOperand(Object? operand) → Object?
Decodes what encodeFilterOperand wrote.
defaultCompareFor(ColumnType type) → Comparator<Object?>
The comparison a column of type orders by when it declares no GridColumn.comparator of its own.
describeHeaderProblems<T>(List<HeaderRow> rows, List<GridColumn<T>> columns) → List<String>
Validates rows against columns, returning a message per problem.
encodeFilterOperand(Object? operand) → Object?
Encodes a filter operand as something jsonEncode accepts.
flattenGroups<T>(List<GroupNode<T>> nodes, GroupExpansionState expansion, {Set<String> loadingPaths = const {}, int sourceIndexOf(T row)?}) → List<GridRow<T>>
Flattens nodes into visible rows, skipping the contents of collapsed groups.
flattenNestedRows<T>(List<T> roots, {required List<T> childrenOf(T row), required Object keyOf(T row)}) → NestedRows<T>
Flattens a nested model into the rows and parent references a grid can filter, search and sort.
flattenTree<T>({required List<T> rows, required TreeSpec<T> spec, required Object keyOf(T row), required GroupExpansionState expansion, Map<Object, List<T>> loadedChildren = const {}, Set<Object> loadingKeys = const {}, Comparator<T>? childComparator, T substitute(T row)?, int sourceIndexOf(T row)?}) → List<GridRow<T>>
Flattens rows into the visible rows of a tree, skipping what is closed.
foldText(String text) → String
Lowercases text and strips the diacritics the Latin alphabet writes with, so that Crème folds to creme and sorts next to cream.
groupPathSegment(String field, Object? key) → String
One segment of a GroupNode.path.
layoutHeaderRow<T>(List<ColumnLayout<T>> pane, HeaderRow row, {Set<HeaderBand>? drawn}) → List<HeaderBandLayout<T>>
Resolves row against one pane's laid-out columns.
naturalSortKey(Object? value) → String
A key that sorts like compareValuesNatural under a plain string comparison, for use as a GridColumn.sortKey.
numberRange({num? min, num? max, String? message}) → ValueValidator
Builds a validator bounding a numeric column.
operatorsFor(ColumnType type) → List<FilterOperator>
The operators worth offering for a column of type, most useful first.
orderColumnsForDisplay<T>(List<GridColumn<T>> columns) → List<GridColumn<T>>
Orders columns the way they appear on screen: the columns pinned to the leading edge, then the scrolling ones, then the columns pinned to the trailing edge, each group keeping its relative order.
parseClipboardText(String text, {String delimiter = '\t'}) → List<List<String>>
Splits clipboard text back into a grid of cells: the inverse of toClipboardText.
parseDecimal(String text) → num?
Parses text as a finite decimal number, or returns null.
pathKeySegment(Object? key) → String
One key, encoded with its type so that two keys of different types cannot produce the same path.
pruneFilter(Filter? filter, bool isKnown(String field)) → Filter?
Drops the conditions in filter whose field isKnown rejects.
requiredValue([String message = 'Required']) → ValueValidator
Builds a validator that rejects empty values.
requireSupportedSchema(Map<String, Object?> json, {required String what}) → int
Reads and checks the version of a serialised what.
rootsOf<T>(List<T> rows, Object? parentOf(T row), Object keyOf(T row), Set<Object> present, List<T> childrenOf(T row)) → List<T>
The rows to draw at depth zero of a flat, parent-referencing model.
searchFilter(String needle, List<String> fields) → Filter
Convenience filter for a quick-search box, matching needle against any of fields with contains.
sortOrder<T>(List<T> rows, List<SortSpec> sorts, Map<String, GridColumn<T>> columns) → List<int>
The permutation sortRows applies: positions in rows, in sorted order.
sortRows<T>(List<T> rows, List<SortSpec> sorts, Map<String, GridColumn<T>> columns) → List<T>
Returns a new list of rows ordered by sorts, preserving the original order of rows that compare equal.
toClipboardText<T>(List<List<String>> cells, {String delimiter = '\t', bool sanitizeFormulas = true, String formulaPrefix = "'"}) → String
Serialises a cell range as tab-separated text, the format spreadsheets and most editors accept from the clipboard.
valuesEqualFolded(Object? a, Object? b) → bool
Whether a and b are the same value, ignoring case and accents in text.
withDetailRows<T>(List<GridRow<T>> rows, {required Set<Object> open, required double height, required Object keyOf(T row)}) → List<GridRow<T>>
Inserts a DetailGridRow after every row whose panel is open, renumbering the rows as it goes.

Typedefs

GridChangeListener = void Function(Set<GridChange> changes)
Callback invoked with what changed.
GridListener = void Function()
Callback invoked when an observable object changes.
ValueFormatter = String Function(Object? value)
Renders a raw value as display text.
ValueGetter<T> = Object? Function(T row)
Reads the value of a column out of a row object.
ValueSetter<T> = T? Function(T row, Object? value)
Writes an edited value back into a row object.
ValueValidator = String? Function(Object? value)
Validates a candidate value, returning an error message or null if valid.

Exceptions / Errors

FetchCancelled
Thrown by a data source that notices its fetch was cancelled.