# requestRoster method

Future <Result<RosterRequestResult, RosterError>> requestRoster(

1. {bool useRosterVersion = true}

)

Requests the roster following RFC 6121. If `useRosterVersion` is set to false, then roster versioning will not be used, even if the server supports it and we have a last known roster version.

## Implementation

    Future<Result<RosterRequestResult, RosterError>> requestRoster({
      bool useRosterVersion = true,
    }) async {
      final attrs = getAttributes();
      final query = XMLNode.xmlns(
        tag: 'query',
        xmlns: rosterXmlns,
      );
      final rosterVersion = await _stateManager.getRosterVersion();
      if (rosterVersion != null &&
          rosterVersioningAvailable() &&
          useRosterVersion) {
        query.attributes['ver'] = rosterVersion;
      }

      final response = (await attrs.sendStanza(
        StanzaDetails(
          Stanza.iq(
            type: 'get',
            children: [
              query,
            ],
          ),
        ),
      ))!;

      if (response.attributes['type'] != 'result') {
        logger.warning('Error requesting roster: ${response.toXml()}');
        return Result(UnknownError());
      }

      final responseQuery = response.firstTag('query', xmlns: rosterXmlns);
      return _handleRosterResponse(responseQuery, rosterVersion);
    }