select method
Sets the flair for the current Submission.
flairTemplateId
is the name of the FlairTemplate retrieved from
choices()
. If the FlairTemplate allows for editable text, providing
text
will be set as the custom text. text
must be shorter than 64
characters.
Implementation
Future<void> select(String flairTemplateId, {String text = ''}) async {
if (text.length > 64) {
throw DRAWArgumentError("Argument 'text' must not be longer than"
' 64 characters');
}
final data = <String, String>{
'flair_template_id': flairTemplateId,
'link': _submission.fullname!,
'text': text,
};
final url = apiPath['select_flair']
.replaceAll(_kSubredditRegExp, _submission.subreddit.displayName);
await _submission.reddit.post(url, data, discardResponse: true);
}