SupabaseStorageClient constructor Null safety

SupabaseStorageClient(
  1. String url,
  2. Map<String, String> headers,
  3. {Client? httpClient,
  4. int retryAttempts = 0}
)

To create a SupabaseStorageClient, you need to provide an url and headers.

SupabaseStorageClient(STORAGE_URL, {'apikey': 'foo'});

httpClient is optional and can be used to provide a custom http client

retryAttempts specifies how many retry attempts there should be to upload a file when failed due to network interruption.

Time between each retries are set as the following:

  1. 400 ms +/- 25%
  2. 800 ms +/- 25%
  3. 1600 ms +/- 25%
  4. 3200 ms +/- 25%
  5. 6400 ms +/- 25%
  6. 12800 ms +/- 25%
  7. 25600 ms +/- 25%
  8. 30000 ms +/- 25%

Anything beyond the 8th try will have 30 second delay.

Implementation

SupabaseStorageClient(
  String url,
  Map<String, String> headers, {
  Client? httpClient,
  int retryAttempts = 0,
})  : assert(
        retryAttempts >= 0,
        'retryAttempts has to be great than or equal to 0',
      ),
      _defaultRetryAttempts = retryAttempts,
      super(
        url,
        {...Constants.defaultHeaders, ...headers},
        httpClient: httpClient,
      );