AttachedFile.fromFile constructor

AttachedFile.fromFile(
  1. File file,
  2. String name, {
  3. bool? spoiler,
  4. String? proxyUrl,
  5. int? height,
  6. int? width,
  7. String? contentType,
  8. String? description,
})

Creates an AttachedFile from a local file.

Example:

final file = File('assets/image.png');
final attachedFile = AttachedFile.fromFile(file, 'image.png', spoiler: false);

Implementation

factory AttachedFile.fromFile(
  File file,
  String name, {
  bool? spoiler,
  String? proxyUrl,
  int? height,
  int? width,
  String? contentType,
  String? description,
}) {
  final mediaItem = MediaItem.fromFile(
    file,
    name,
    spoiler: spoiler,
    proxyUrl: proxyUrl,
    height: height,
    width: width,
    contentType: contentType,
    description: description,
  );
  return AttachedFile._(mediaItem);
}