fromApi static method

String fromApi(
  1. String? value, {
  2. String outputPattern = defaultFormat,
  3. List<String> inputPatterns = apiInputFormats,
  4. String fallbackValue = fallback,
  5. String? locale,
  6. bool toLocal = true,
})

Backward-compatible alias for API string formatting.

Implementation

static String fromApi(
  String? value, {
  String outputPattern = defaultFormat,
  List<String> inputPatterns = apiInputFormats,
  String fallbackValue = fallback,
  String? locale,
  bool toLocal = true,
}) {
  final parsed = parse(
    value,
    inputPatterns: inputPatterns,
    toLocal: toLocal,
  );
  if (parsed == null) {
    return fallbackValue;
  }
  return formatDate(parsed, format: outputPattern, locale: locale);
}