getEntityText method
It returns the text of a given message entity.
Implementation
String? getEntityText(MessageEntityType type) {
final entity = getMessageEntity(type);
if (entity == null || entity.offset == null || entity.length == null) {
return null;
}
final content = text ?? caption;
if (content == null) return null;
final start = entity.offset!;
final end = start + entity.length!;
if (start >= 0 && end <= content.length) {
return content.substring(start, end);
}
return null;
}