tryParseColor function

Color? tryParseColor(
  1. String? input, {
  2. Logger? logger,
})

Implementation

Color? tryParseColor(String? input, {Logger? logger}) {
  if (input == null) return null;

  try {
    return parseCssHexColor(input);
  } catch (e, st) {
    // The user can manipulate the query string so if the value is invalid
    // print the value but otherwise continue.
    logger?.warning(
      'Failed to parse "$input" as a color from the querystring, ignoring: $e',
      e,
      st,
    );
    return null;
  }
}