MediaItem.fromFile constructor
MediaItem.fromFile(})
Implementation
factory MediaItem.fromFile(
File file,
String name, {
bool? spoiler,
String? proxyUrl,
int? height,
int? width,
String? contentType,
String? description,
}) {
if (!file.existsSync()) {
throw ArgumentError('File ${file.path} does not exist');
}
if (name.isEmpty) {
throw ArgumentError("Name can't be empty.");
}
final bytes = file.readAsBytesSync();
return MediaItem._(
'attachment://$name',
spoiler: spoiler,
proxyUrl: proxyUrl,
height: height,
width: width,
contentType: contentType,
description: description,
)..bytes = bytes;
}