fromFile static method

Future<FileAttachment> fromFile(
  1. XFile file
)

Creates a FileAttachment from an XFile.

This factory method asynchronously reads the file content and determines its MIME type.

file is the XFile object representing the file to be attached.

Returns a Future that completes with a FileAttachment instance.

Implementation

static Future<FileAttachment> fromFile(XFile file) async =>
    FileAttachment.fileOrImage(
      name: file.name,
      mimeType: Attachment._mimeType(file),
      bytes: await file.readAsBytes(),
    );