InputFile class
This class is used to represent a file to be sent.
Currently we have three ways to send a file:
- Use the file id.
- Use the file path.
- Use the file url.
The InputFile class has three separate constructors for each of these methods.
For example, if you want to send a file using the file id, you can use the InputFile.fromFileId constructor.
// Simply create an InputFile using the file id.
var photo = InputFile.fromFileId('file_id');
// Then pass the InputFile to the method that requires a file.
bot.sendPhoto(chatId, photo);
Constructors
-
InputFile.fromBytes(Uint8List bytes, {String? name, String? mimeType, Map<
String, List< ? headers})String> > -
Creates a new InputFile using the bytes of the file.
factory
-
InputFile.fromFile(File file, {String? name, String? mimeType, Map<
String, List< ? headers})String> > -
Creates a new InputFile using a local file.
factory
- InputFile.fromFileId(String fileId, {String? name})
-
Creates a new InputFile using the File ID on the Telegram Servers.
factory
- InputFile.fromUrl(String url, {String? name})
-
Creates a new InputFile using the file url.
factory
Properties
- bytes → Uint8List?
-
The bytes of the file.
final
- fileId → String?
-
Unique identifier for this file
final
- hashCode → int
-
The hash code for this object.
no setterinherited
-
headers
→ Map<
String, List< ?String> > -
Additional headers
final
- mimeType → String?
-
Mime Type of the File
final
- name → String?
-
The name of the file to be sent.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- type → InputFileType
-
Returns the type of the InputFile.
no setter
- url → Uri?
-
URL of the file to be sent. Use either this field or fileId to specify a file.
final
Methods
-
getBytes(
) → Uint8List - Get bytes of either the file or the bytes itself.
-
getValue(
[String? field]) → String - Returns the file name of the InputFile.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited