t×tecexpressby TeKOcloud
DEv0.7.1
API & types / FLUTTER

TxUploadAdapter.

Asynchronous callback uploading one file; its result reaches the success callback and errors reach error handling.

dart
typedef TxUploadAdapter = Future<Object?> Function(TxFile file, TxUploadContext context);
dart
import 'dart:typed_data';
import 'package:tecexpress/tecexpress.dart';

Future<void> example() async {
  TxUploadAdapter adapter = (file, context) async {
    context.cancellation.throwIfCancelled();
    final size = await file.length();
    context.onProgress(size, size);
    return file.name;
  };
  print(await adapter(TxFile.fromData(Uint8List(0), name: 'empty.txt'), TxUploadContext(cancellation: TxCancellation(), onProgress: (loaded, total) {})));
}