InternetCheckOption constructor

InternetCheckOption({
  1. required Uri uri,
  2. Duration timeout = const Duration(seconds: 3),
  3. Map<String, String> headers = const {},
  4. ResponseStatusFn? responseStatusFn,
})

Creates an InternetCheckOption instance.

Options for checking the internet connectivity to an address.

This class provides a way to specify options for checking the connectivity of an address. It includes the URI to check and the timeout duration for the HEAD request.

Usage Example:

final options = InternetCheckOption(
  uri: Uri.parse('https://example.com'),
  timeout: Duration(seconds: 5),
  headers: {
     'Authorization': 'Bearer token',
  },
);

With custom responseStatusFn callback:

final options = InternetCheckOption(
  uri: Uri.parse('https://example.com'),
  timeout: Duration(seconds: 5),
  headers: {
     'Authorization': 'Bearer token',
  },
  responseStatusFn: (response) {
    return response.statusCode >= 200 && response.statusCode < 300,
  },
);

Implementation

InternetCheckOption({
  required this.uri,
  this.timeout = const Duration(seconds: 3),
  this.headers = const {},
  ResponseStatusFn? responseStatusFn,
}) : responseStatusFn = responseStatusFn ?? defaultResponseStatusFn;