getAttachmentUrlForMessage method
Obtains the file attached to the message.
Implementation
Future<CatapushFile> getAttachmentUrlForMessage(
CatapushMessage message) async {
if (!message.hasAttachment) {
return Future.error('Message has no attachment');
}
return _channel.invokeMethod<Map<Object?, Object?>>(
'Catapush#getAttachmentUrlForMessage', {
'id': message.id,
}).then((response) {
if ((response?['url'] as String?)?.isNotEmpty ?? false) {
return CatapushFile(
response!['mimeType'] as String? ?? '',
response['url']! as String,
);
}
return Future.error("Can't retrieve attachment");
});
}