prompt function

String prompt(
  1. String message, {
  2. String? defaultValue,
  3. String? validatorErrorMessage,
})

Prompts the user for text input.

Implementation

String prompt(
  String message, {
  String? defaultValue,
  String? validatorErrorMessage,
}) {
  return Input.withTheme(
    theme: inputTheme,
    prompt: message,
    validator: (input) {
      if (input.isEmpty) {
        throw ValidationError(validatorErrorMessage ?? 'Input cannot be empty');
      }
      return true;
    },
    defaultValue: defaultValue,
  ).interact();
}