calcLocalizedBody method

Future<String> calcLocalizedBody(
  1. SDNLocalizations i18n, {
  2. bool withSenderNamePrefix = false,
  3. bool hideReply = false,
  4. bool hideEdit = false,
  5. bool plaintextBody = false,
  6. bool removeMarkdown = false,
})

Returns a localized String representation of this event. For a room list you may find withSenderNamePrefix useful. Set hideReply to crop all lines starting with '>'. With plaintextBody it'll use the plaintextBody instead of the normal body. removeMarkdown allow to remove the markdown formating from the event body. Usefull form message preview or notifications text.

Implementation

Future<String> calcLocalizedBody(SDNLocalizations i18n,
    {bool withSenderNamePrefix = false,
    bool hideReply = false,
    bool hideEdit = false,
    bool plaintextBody = false,
    bool removeMarkdown = false}) async {
  if (redacted) {
    await redactedBecause?.fetchSenderUser();
  }

  if (withSenderNamePrefix &&
      (type == EventTypes.Message || type.contains(EventTypes.Encrypted))) {
    // To be sure that if the event need to be localized, the user is in memory.
    // used by EventLocalizations._localizedBodyNormalMessage
    await fetchSenderUser();
  }

  return calcLocalizedBodyFallback(i18n,
      withSenderNamePrefix: withSenderNamePrefix,
      hideReply: hideReply,
      hideEdit: hideEdit,
      plaintextBody: plaintextBody,
      removeMarkdown: removeMarkdown);
}