gpt4 book ai didi

android - 在flutter中使用setchanged方法时如何禁用ui build

转载 作者:行者123 更新时间:2023-12-03 04:40:37 24 4
gpt4 key购买 nike

我有一个图形 View 我的应用程序,只要我的函数起作用,它也会重新构建
如何控制我的UI

var response = await getdashboarddata(tokenkey);
setState(() {

});

最佳答案

使用FutureBuilder

 Widget projectWidget() {
return FutureBuilder(
builder: (context, projectSnap) {
if (projectSnap.connectionState == ConnectionState.none &&
projectSnap.hasData == null) {
//print('project snapshot data is: ${projectSnap.data}');
return Container();
}
return ListView.builder(
itemCount: projectSnap.data.length,
itemBuilder: (context, index) {
ProjectModel project = projectSnap.data[index];
return Column(
children: <Widget>[
// Widget to display the list of project
],
);
},
);
},
future: getdashboarddata(tokenkey),
);
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('ProjectList'),
),
body: projectWidget(),
);
}

关于android - 在flutter中使用setchanged方法时如何禁用ui build,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63325143/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com