FileMessage.from constructor

FileMessage.from({
  1. String? path,
  2. Uint8List? binaryData,
  3. String? url,
  4. String? format,
  5. String? name,
})

To create a new FileMessage from path or binaryData or url.

path is for the local path of the local file. binaryData is for the binary data of the local file. url is for the URL of the remote file. format is for the FileMessage.format, it is optional. name is optional, if provide, the FileMessage.url will has a name suffix.

Important: You must provide only one of parameters in path, binaryData and url.

Implementation

FileMessage.from({
  String? path,
  Uint8List? binaryData,
  String? url,
  String? format,
  String? name,
}) {
  int count = 0;
  if (path != null) {
    count += 1;
  }
  if (binaryData != null) {
    count += 1;
  }
  if (url != null) {
    count += 1;
  }
  if (count != 1) {
    throw ArgumentError(
      'must provide only one of parameters in [path], [binaryData] and [url].',
    );
  }
  _filePath = path;
  _fileData = binaryData;
  _fileUrl = url;
  _fileFormat = format;
  _fileName = name;
}