copyWith method
GridColumn<T>
copyWith({
- String? field,
- String? title,
- ValueGetter<
T> ? value, - ColumnType? type,
- double? width,
- double? minWidth,
- double? maxWidth,
- ColumnAlign? align,
- bool clearAlign = false,
- ColumnPin? pin,
- bool? visible,
- bool? sortable,
- bool? filterable,
- bool? resizable,
- bool? groupable,
- ValueFormatter? format,
- bool clearFormat = false,
- Comparator<
Object?> ? comparator, - bool clearComparator = false,
- ValueSetter<
T> ? setValue, - bool clearSetValue = false,
- ValueValidator? validator,
- bool clearValidator = false,
- String? tooltip,
- bool clearTooltip = false,
- CellRule? rule,
- bool clearRule = false,
- Object? sortKey(
- T row
- bool clearSortKey = false,
A copy of this column with the given fields replaced.
A null argument means "keep what is there", which is why every
nullable field has a clear flag beside it: without one there was no
way to remove a callback, so a column with a setValue could never be
made read-only and a rule could never be taken off a column.
Changing field also regenerates the default Map accessor, so a
column declared without a value: reads the new field rather than
quietly keeping the old one.
Implementation
GridColumn<T> copyWith({
String? field,
String? title,
ValueGetter<T>? value,
ColumnType? type,
double? width,
double? minWidth,
double? maxWidth,
ColumnAlign? align,
bool clearAlign = false,
ColumnPin? pin,
bool? visible,
bool? sortable,
bool? filterable,
bool? resizable,
bool? groupable,
ValueFormatter? format,
bool clearFormat = false,
Comparator<Object?>? comparator,
bool clearComparator = false,
ValueSetter<T>? setValue,
bool clearSetValue = false,
ValueValidator? validator,
bool clearValidator = false,
String? tooltip,
bool clearTooltip = false,
CellRule? rule,
bool clearRule = false,
Object? Function(T row)? sortKey,
bool clearSortKey = false,
}) {
final nextField = field ?? this.field;
// A column that never had an accessor of its own reads whichever field it
// now names; one that was given an accessor keeps it.
final nextValue = value ??
(_usesDefaultValue && nextField != this.field ? null : this.value);
return GridColumn<T>(
field: nextField,
title: title ?? this.title,
value: nextValue,
type: type ?? this.type,
width: width ?? this.width,
minWidth: minWidth ?? this.minWidth,
maxWidth: maxWidth ?? this.maxWidth,
align: clearAlign ? null : (align ?? this.align),
pin: pin ?? this.pin,
visible: visible ?? this.visible,
sortable: sortable ?? this.sortable,
filterable: filterable ?? this.filterable,
resizable: resizable ?? this.resizable,
groupable: groupable ?? this.groupable,
format: clearFormat ? null : (format ?? this.format),
comparator: clearComparator ? null : (comparator ?? this.comparator),
setValue: clearSetValue ? null : (setValue ?? this.setValue),
validator: clearValidator ? null : (validator ?? this.validator),
tooltip: clearTooltip ? null : (tooltip ?? this.tooltip),
rule: clearRule ? null : (rule ?? this.rule),
sortKey: clearSortKey ? null : (sortKey ?? this.sortKey),
);
}