search method

Future<SearchResults> search({
  1. required String query,
  2. String? type,
})

Perform query search, optional type filter (e.g. 'boardgame').

Throws:

  • BggRequestPendingException if API returns 202
  • BggNetworkException on network errors
  • BggParsingException on XML parse errors

Implementation

Future<SearchResults> search({
  required String query,
  String? type,
}) async {
  try {
    final xmlString = await _api.fetchSearch(query: query, type: type);
    final root = XmlDocument.parse(xmlString).rootElement;
    return SearchResults.fromXml(root);
  } on BggException {
    rethrow;
  } catch (_) {
    throw BggParsingException();
  }
}