flair method

Future<void> flair({
  1. String text = '',
  2. String cssClass = '',
})

Sets the flair for the Submission.

text is the flair text to be associated with the Submission. cssClass is the CSS class to associate with the flair HTML.

This method can only be used by an authenticated user who has moderation rights for this Submission.

Implementation

Future<void> flair({String text = '', String cssClass = ''}) async {
  final data = {
    'css_class': cssClass,
    'link': _content.fullname,
    'text': text,
  };
  var subreddit = _content.subreddit;
  if (subreddit is! Subreddit) {
    subreddit = await subreddit.populate();
  }
  final url =
      apiPath['flair'].replaceAll(_subModRegExp, subreddit.displayName);
  await _content.reddit.post(url, data, discardResponse: true);
}