[英]How to disable graphql_flutter query backend every time build Query()
I got a PageView
in the home page with Query
for a list of data, and every time push to another route will causing build
. 我在首页上有了一个PageView
,其中包含Query
以获取数据列表,并且每次推送到另一条路线都会导致build
。 And the Query
in build
will call backend Api and rerender. build
的Query
将调用后端Api并重新渲染。 How to avoid the query? 如何避免查询?
Query
widget init in initState
won't work 无法禁用构建方法,并使initState
的Query
小部件init无法正常工作 @override
Widget build(BuildContext context) {
return Query(
options: QueryOptions(
document: queryDocument,
),
builder: (QueryResult result, {VoidCallback refetch, FetchMore fetchMore}) {
print('will call backend each push and pop route and the build causing by state changes');
}
);
}
Expect the builder won't be alway call and to reduce the backend query. 期望构建器永远不会被调用并减少后端查询。 (I'm new to graphql_flutter and the document is not cover such case.) (我是graphql_flutter的新手,而本文不涉及这种情况。)
The issue is resolved in the next beta version https://pub.dev/packages/graphql_flutter/versions/2.1.1-beta.2 该问题在下一测试版https://pub.dev/packages/graphql_flutter/versions/2.1.1-beta.2中得到解决
See: https://github.com/zino-app/graphql-flutter/issues/412 参见: https : //github.com/zino-app/graphql-flutter/issues/412
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.