addPrompt method

void addPrompt(
  1. Prompt prompt,
  2. FutureOr<GetPromptResult> impl(
    1. GetPromptRequest
    )
)

Adds a prompt and notifies clients that the list has changed.

Implementation

void addPrompt(
  Prompt prompt,
  FutureOr<GetPromptResult> Function(GetPromptRequest) impl,
) {
  if (_prompts.containsKey(prompt.name)) {
    throw StateError(
      'Failed to add prompt ${prompt.name}, it already exists',
    );
  }
  _prompts[prompt.name] = prompt;
  _promptImpls[prompt.name] = impl;
  if (ready) {
    _notifyPromptListChanged();
  }
}