validateNetworkInput method

  1. @protected
void validateNetworkInput(
  1. String url,
  2. String fileName
)

Validates input for saveNetwork.

Implementation

@protected
void validateNetworkInput(String url, String fileName) {
  if (url.isEmpty) {
    throw const InvalidInputException('URL cannot be empty');
  }
  final uri = Uri.tryParse(url);
  if (uri == null ||
      !uri.hasScheme ||
      (!uri.isScheme('http') && !uri.isScheme('https'))) {
    throw const InvalidInputException('URL must use http or https scheme');
  }
  if (fileName.isEmpty) {
    throw const InvalidInputException('File name cannot be empty');
  }
}