requireDelegate function

void requireDelegate(
  1. TaskCapabilities capabilities,
  2. Delegate delegate
)

Fails with the capability query's reason when delegate is unavailable, so every task's create refuses a delegate the same way on every platform.

Implementation

void requireDelegate(TaskCapabilities capabilities, Delegate delegate) {
  if (capabilities.supportedDelegates.contains(delegate)) return;
  throw RuntimeUnavailableException(
    'The ${delegate.name.toUpperCase()} delegate is unavailable here.',
    fix:
        capabilities.unavailableReasons[delegate] ??
        'Choose a delegate the capability query reports as supported.',
  );
}