runWithBlockUi<T> function

T runWithBlockUi<T>(
  1. T callback()
)

Block the ui thread to ensure that the mapkit state does not change until callback is completed. callback must be synchronous function.

Implementation

T runWithBlockUi<T>(T Function() callback) {
  if (callback is Future<void> Function()) {
    throw ArgumentError('must be synchronous function', 'callback');
  }

  if (_uiBlocked) {
    return callback();
  }

  final context = _runWithBlockUiStart();
  try {
    _uiBlocked = true;
    return callback();
  } finally {
    _uiBlocked = false;
    _runWithBlockUiStop(context);
  }
}