maybe static method

PassWebService? maybe({
  1. String? authenticationToken,
  2. String? webServiceURL,
})

returns a PassWebService in case authenticationToken and webServiceURL are both valid values.

Implementation

static PassWebService? maybe({
  String? authenticationToken,
  String? webServiceURL,
}) {
  if (authenticationToken == null || webServiceURL == null) return null;
  // normalize the end of the URL
  if (webServiceURL.endsWith('/')) {
    webServiceURL = webServiceURL.substring(0, webServiceURL.length - 1);
  }
  final uri = Uri.tryParse(webServiceURL);
  if (uri == null || uri.scheme != 'https') return null;
  return PassWebService(
    authenticationToken: authenticationToken,
    webServiceURL: uri,
  );
}