...
@override
Future<List<String>> searchPosts({
required String author,
required String title,
required String content,
}) async {
_postsSearcher.applyState(
(state) => state.copyWith(
query: content,
page: 0,
hitsPerPage: 1,
facetFilters: [
'author:$author',
'title:$title',
],
),
);
final results = await _searchPage.first;
final postIds = results.items.map((post) => post.postId).toList();
return postIds;
}
}
class HitsPage {
const HitsPage(this.items, this.pageKey, this.nextPageKey);
factory HitsPage.fromResponse(SearchResponse response) {
final items = response.hits.map(PostModel.fromJson).toList();
final isLastPage = response.page >= response.nbPages;
final nextPageKey = isLastPage ? null : response.page + 1;
return HitsPage(items, response.page, nextPageKey);
}
final List<PostModel> items;
final int pageKey;
final int? nextPageKey;
}
I’m developing in Flutter and made a button that calls:Future<List<String>> searchPosts. (Clean Architecture setup)
It works fine the first time but when I click the button the second time, the app is stuck at
final results = await _searchPage.first;
Any ideas?
I reckon it has something to do with Stream but not sure. Also, why does it just hang?