transferFileInfo method

Future<FileTransfer?> transferFileInfo(
  1. File file, {
  2. Map<String, dynamic> metadata = const {},
})

Transfer a File to WatchOS companion app

You can track the transfering progress implicitly with onProgressChanged handler.

Return a FileTransfer

Implementation

Future<FileTransfer?> transferFileInfo(File file,
    {Map<String, dynamic> metadata = const {}}) async {
  Map<String, dynamic> mMetadata = Map<String, dynamic>.from(metadata);

  mMetadata["id"] = getRandomString(20);
  var rawFileTransferInMap = await channel.invokeMethod(
      "transferFileInfo", {"filePath": file.path, "metadata": mMetadata});
  if (rawFileTransferInMap != null && rawFileTransferInMap is Map) {
    Map<String, dynamic> fileTransferInJson =
        rawFileTransferInMap.toMapStringDynamic();
    return _mapIdAndConvertFileTransfer(fileTransferInJson);
  }
  return null;
}