parseUri function

Uri parseUri(
  1. String value
)

Parses a URI from the given value and returns it as a Uri.

  • Throws a FormatException if the value is empty or contains an invalid URI.

Implementation

Uri parseUri(final String value) {
  if (value.isEmpty) {
    throw const FormatException('Value cannot be empty');
  }

  try {
    return Uri.parse(value);
  } catch (e) {
    throw const FormatException('Invalid URI format');
  }
}