applyPersistedColumnState method
void
applyPersistedColumnState(
{ - String? tableId,
})
inherited
Implementation
void applyPersistedColumnState({String? tableId}) {
try {
final persistedState = ColumnStatePersistenceService.loadColumnState(tableId: tableId);
if (persistedState == null || buildedHeaderRows.isEmpty) {
return;
}
final columns = buildedHeaderRows.last.columns;
final useSourceKeys = _hasUniqueSourceColumnIndexes(columns);
for (var columnIndex = 0; columnIndex < columns.length; columnIndex++) {
final state = persistedState[useSourceKeys ? columns[columnIndex].sourceColumnIndex : columnIndex];
if (state == null) {
continue;
}
if (state.width != null) {
columns[columnIndex].width.value = state.width;
}
if (state.userResized) {
markColumnUserResized(columnIndex);
}
if (state.visible != null) {
columns[columnIndex].visible.value = state.visible!;
}
if (state.pinLeft != null) {
columns[columnIndex].pinLeft.value = state.pinLeft!;
}
if (state.pinRight != null) {
columns[columnIndex].pinRight.value = state.pinRight!;
}
}
synchronizeGroupedHeaderVisibility();
synchronizeGroupedHeaderPinning();
} catch (error) {
debugPrint('Error applying persisted column state: $error');
}
}