tryParse static method

OutputFormat? tryParse(
  1. String? value
)

Parses a format string (case-insensitive).

Accepts the canonical names (plain, csv, json, md) plus the documented aliases text (→ plain) and markdown (→ md). Returns null for null, an empty string, or an unrecognized value.

Implementation

static OutputFormat? tryParse(String? value) {
  if (value == null) return null;
  return switch (value.toLowerCase()) {
    'plain' || 'text' => plain,
    'csv' => csv,
    'json' => json,
    'md' || 'markdown' => md,
    _ => null,
  };
}