UpChunk constructor

UpChunk({
  1. required String endPoint,
  2. required XFile file,
  3. Map<String, String> headers = const {},
  4. int chunkSize = 5120,
  5. int attempts = 5,
  6. int delayBeforeAttempt = 1,
  7. void onOnline()?,
  8. void onOffline()?,
  9. void onAttempt(
    1. int chunkNumber,
    2. int chunkSize
    )?,
  10. void onAttemptFailure(
    1. String message,
    2. int chunkNumber,
    3. int attemptsLeft
    )?,
  11. void onError(
    1. String message,
    2. int chunk,
    3. int attempts
    )?,
  12. void onSuccess()?,
  13. void onProgress(
    1. double progress
    )?,
  14. String? connectionCheckEndpoint,
  15. int? chunkStart,
})

Internal constructor used by createUpload

Implementation

UpChunk({
  required this.endPoint,
  required this.file,
  this.headers = const {},
  this.chunkSize = 5120,
  this.attempts = 5,
  this.delayBeforeAttempt = 1,
  this.onOnline,
  this.onOffline,
  this.onAttempt,
  this.onAttemptFailure,
  this.onError,
  this.onSuccess,
  this.onProgress,
  this.connectionCheckEndpoint,
  int? chunkStart,
}) {
  _validateOptions();

  _chunkByteSize = chunkSize * 1024;
  if (chunkStart != null) {
    _chunkCount = chunkStart;
  }
  // restart sync when back online
  // trigger events when offline/back online
  var checkEndpoint = connectionCheckEndpoint != null
    ? connectionCheckEndpoint!
    : _endPointUri.origin;
  _internetConnection = InternetConnection.createInstance(
    customCheckOptions: [
      InternetCheckOption(uri: Uri.parse(checkEndpoint)),
    ],
    useDefaultOptions: false,
  );

  _internetConnection.onStatusChange.listen(_connectionChanged);

  _initialize();
}