CellScope<T extends DataGridRow> class

Scoped inherited widget that provides per-cell data to descendant widgets.

Columns declare a DataGridColumn.cellWidget (ideally const) and read row/column/selection data from the nearest CellScope ancestor.

This lets Flutter preserve element identity across rebuilds — the const child widget never changes, so the framework skips subtree diffing entirely. Only widgets that call CellScope.of are rebuilt when the underlying data actually changes.

// On the column:
DataGridColumn<MyRow>(
  id: 1,
  title: 'Price',
  width: 100,
  cellWidget: const PriceCell(),
)

// The cell widget:
class PriceCell extends StatelessWidget {
  const PriceCell({super.key});
  @override
  Widget build(BuildContext context) {
    final scope = CellScope.of<MyRow>(context);
    return Text('\$${scope.row.price}');
  }
}
Inheritance

Constructors

CellScope({Key? key, required T row, required DataGridColumn<T> column, required int rowIndex, required bool isSelected, required bool isPinned, required dynamic value, required DataGridController<T> controller, required Widget child})
Creates a CellScope providing cell data to descendants.
const

Properties

child → Widget
The widget below this widget in the tree.
finalinherited
column → DataGridColumn<T>
The column configuration for this cell.
final
controller → DataGridController<T>
The grid controller for dispatching events.
final
hashCode → int
The hash code for this object.
no setterinherited
isPinned → bool
Whether the column containing this cell is pinned.
final
isSelected → bool
Whether the row containing this cell is selected.
final
key → Key?
Controls how one widget replaces another widget in the tree.
finalinherited
row → T
The typed row object for this cell.
final
rowIndex → int
Zero-based visible row index.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
value → dynamic
Pre-computed value from DataGridColumn.valueAccessor, if any.
final

Methods

createElement() → InheritedElement
Inflates this configuration to a concrete instance.
inherited
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
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep.
inherited
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
updateShouldNotify(covariant CellScope<T> oldWidget) → bool
Whether the framework should notify widgets that inherit from this widget.
override

Operators

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

Static Methods

maybeOf<T extends DataGridRow>(BuildContext context) → CellScope<T>?
Returns the nearest CellScope ancestor, or null if none exists.
of<T extends DataGridRow>(BuildContext context) → CellScope<T>
Returns the nearest CellScope ancestor, throwing if none exists.