uidSortMessages method
Future<SortImapResult>
uidSortMessages(
- String sortCriteria, [
- String searchCriteria = 'ALL',
- String charset = 'UTF-8',
- List<
ReturnOption> ? returnOptions,
Sorts messages by the given criteria
sortCriteria the criteria used for sorting the results
like 'ARRIVAL' or 'SUBJECT'
searchCriteria the criteria like 'UNSEEN' or 'RECENT'
charset the charset used for the searching criteria
When augmented with zero or more returnOptions, requests
an extended search.
The server needs to expose the
SORT capability for this
command to work.
Implementation
Future<SortImapResult> uidSortMessages(
String sortCriteria, [
String searchCriteria = 'ALL',
String charset = 'UTF-8',
List<ReturnOption>? returnOptions,
]) {
final parser =
SortParser(isUidSort: true, isExtended: returnOptions != null);
final buffer = StringBuffer('UID SORT ');
if (returnOptions != null) {
buffer
..write('RETURN (')
..write(returnOptions.join(' '))
..write(') ');
}
buffer
..write('(')
..write(sortCriteria)
..write(') ')
..write(charset)
..write(' ')
..write(searchCriteria);
final cmdText = buffer.toString();
buffer.clear();
final sortLines = cmdText.split('\n');
final cmd = sortLines.length == 1
? Command(cmdText, writeTimeout: defaultWriteTimeout)
: Command.withContinuation(
sortLines,
writeTimeout: defaultWriteTimeout,
);
return sendCommand<SortImapResult>(cmd, parser);
}