disableControls method

void disableControls({
  1. bool restoreCurrentRecord = false,
})

Suspends notifications to data-aware controls.

Calls may be nested. Use a try/finally block so every call is balanced by enableControls. Dataset operations and typed lifecycle events remain fully active while notifications are suspended.

When restoreCurrentRecord is true, the current record is saved for the active suspension cycle and restored immediately before the outermost enableControls completes. The default is false. If no current record exists, no bookmark is captured and a later nested call may capture one. Nested calls do not replace an already saved record; the first call that successfully captures a bookmark owns it for that suspension cycle.

Implementation

void disableControls({bool restoreCurrentRecord = false}) {
  if (_lifecycleCoordinator.isDisposed) {
    return;
  }

  if (restoreCurrentRecord && !_restoreCurrentRecordOnEnable) {
    final bookmark = _createBookmark();
    if (bookmark != null) {
      _restoreCurrentRecordOnEnable = true;
      _controlsRestoreBookmark = bookmark;
    }
  }
  _controlsDisableCount++;
}