【发布时间】:2020-11-29 19:49:42
【问题描述】:
我有一个连接到 Algolia 以将数据带回我的搜索页面的流构建器,我的问题是,当它找到数据时,即使用户没有输入,它也会不断刷新结果,我认为这对于用户,我需要它在找到数据时暂停,仅在用户开始输入时刷新,以便用户有时间阅读他的结果
这是我的代码
StreamBuilder < List < AlgoliaObjectSnapshot >> (
stream: Stream.fromFuture(_operation(_searchTerm)),
builder: (context, snapshot) {
if (!snapshot.hasData) return Text("Start Typing", style: TextStyle(color: Colors.white), );
else {
List < AlgoliaObjectSnapshot > currSearchStuff = snapshot.data;
switch (snapshot.connectionState) {
case ConnectionState.waiting:
return Container(child: CircularProgressIndicator());
default:
if (snapshot.hasError)
return new Text('Error: ${snapshot.error}');
else
return CustomScrollView(shrinkWrap: true,
slivers: < Widget > [
SliverList(
delegate: SliverChildBuilderDelegate(
(context, index) {
return _searchTerm.length > 0 ? DisplaySearchResult(artDes: currSearchStuff[index].data["name"], artistName: currSearchStuff[index].data["price"].toString(), genre: currSearchStuff[index].data["quantity"].toString(), ) :
Container();
},
childCount: currSearchStuff.length ?? 0,
),
),
],
);
}
}
}),
【问题讨论】:
标签: android firebase flutter dart algolia