GridSheetRow class

Model representing a single data row in a GridSheet.

This class encapsulates all data and metadata for a row including cell values, visual properties, change tracking state, and optimization hooks for efficient rebuilds. Each row is uniquely identified by its key and represents a horizontal slice of the grid's data.

Core Concepts

Data Storage

  • Data: Array of cell values aligned with column indices
  • Index: Current position in the grid (may change with sorting)
  • Key: Stable unique identifier

Change Tracking

  • Existing: Original data from initial load (unmodified)
  • Inserted: Newly created row not yet persisted
  • Modified: Existing row that has been edited
  • Deleted: Row marked for removal (soft delete)

Visual Properties

  • Height: Vertical space allocation for this row
  • Selection: Whether the row is currently selected

Performance Optimization

  • Format Cache: Cached conditional formatting results per column
  • Section SetState: Targeted rebuild callbacks for frozen/scrollable sections

Usage Examples

// Create a new row
final row = GridSheetRow(
  key: ValueKey('row_${DateTime.now().millisecondsSinceEpoch}'),
  index: 0,
  data: ['John Doe', 30, 'john@example.com'],
  height: 40.0,
);

// Create an inserted row
final newRow = GridSheetRow(
  key: ValueKey('row_new_1'),
  index: 0,
  data: ['New User', null, null],
  state: GridSheetRowState.inserted,
);

// Mark a row as modified
row.data = 31;  // Update age[1]
row.markAsModified();

// Soft delete a row
row.markAsDeleted();

// Check row state
if (row.isModified) {
  debugPrint('Row has unsaved changes');
}

State Transitions

[Existing] ──edit──> [Modified]
    │
    └────delete──> [Deleted]

[Inserted] ──edit──> [Inserted] (stays inserted)
    │
    └────delete──> [Removed from grid]

See also:

  • GridSheetColumn, which defines the column structure
  • GridSheetRowState, which defines the state enum
  • GridSheetStateManager.rows, which provides access to all rows
Available extensions

Constructors

GridSheetRow({required ValueKey<String> key, required int index, required List data, List? originalData, bool isSelected = false, double height = 30.0, GridSheetRowState state = GridSheetRowState.existing})
Creates a row for a GridSheet.

Properties

data List
Raw cell values for this row, aligned with column indices.
getter/setter pair
hashCode int
The hash code for this object.
no setteroverride
height double
The visual height of this row in logical pixels.
getter/setter pair
index int
Zero-based position of this row in the current grid view.
getter/setter pair
isDeleted bool
Returns true if this row is marked as deleted.
no setter
isExisting bool
Returns true if this row is unmodified original data.
no setter
isInserted bool
Returns true if this row was newly inserted and not yet persisted.
no setter
isModified bool
Returns true if this row was modified after initial load.
no setter
isSelected bool
Whether this row is currently selected.
getter/setter pair
key ValueKey<String>
Unique identifier for this row.
final
originalData List?
Stores a snapshot of the row's data as it existed before any modifications.
getter/setter pair
rebuildNotifier ValueNotifier<int>
final
rowData List

Available on GridSheetRow, provided by the GridSheetRowExtension extension

Alternative accessor for data.
no setter
rowKey ValueKey<String>?

Available on GridSheetRow, provided by the GridSheetRowExtension extension

Alternative accessor for key.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
state GridSheetRowState
Change-tracking state for this row.
getter/setter pair

Methods

copyWith({ValueKey<String>? key, int? index, List? data, List? originalData, bool? isSelected, double? height, GridSheetRowState? state}) GridSheetRow
dispose() → void
formatCacheForColumn(int colIndex) GridSheetEvaluatedFormatCache
Returns the cached formatting object for the given column index.
markAsDeleted() → void
Marks this row as deleted.
markAsInserted() → void
Marks this row as newly inserted.
markAsModified() → void
Marks this row as modified if it was previously existing.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
rebuildRow() → void
Rebuilds both frozen and scrollable sections of this row.
rowDataToMap(List<GridSheetColumn> columns) Map<String, dynamic>

Available on GridSheetRow, provided by the GridSheetRowExtension extension

toString() String
A string representation of this object.
override

Operators

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