Each search Response contains various metadata you might display in your search experience.
The following information is available as a part of the Response:
hitsPerPage. Number of hits per page.
nbHits. Total number of hits.
nbPages. Total number of pages.
page. Current page.
processingTimeMS. Processing time of the search request (in ms).
query. search query that produced these results.
Examples
class SearchStats extends StatelessWidget {
const SearchStats ( this .responses, { super .key});
final Stream < SearchResponse > responses;
@override
Widget build ( BuildContext context) {
return StreamBuilder < SearchResponse >(
stream : responses,
builder : (context, snapshot) => Text ( stats (snapshot.data)));
}
String stats ( SearchResponse ? response) {
if (response == null ) return '' ;
final buffer = StringBuffer ();
if ( ! response.exhaustiveNbHits) buffer. write ( "~" );
buffer. write ( " ${ response . nbHits } hits " );
buffer. write ( "in ${ response . processingTimeMS } ms" );
return buffer. toString ();
}
}
Last modified on February 4, 2026