如何解决想要在Flutter的ListView中删除索引的项目
有一个订单列表(包含订单),该订单列表是使用综合浏览器构建器(水平滚动)配置的,在每个订单页面中,listview.builder(垂直滚动)中都有项,我能够成功地对其进行动态配置。
现在,每个订单都有n个项目,每个项目都有一个按钮,要求成功执行操作。现在,在成功执行操作之后,我希望应该将已执行操作的订单中的订单项从listview.builder中删除,因为它已在服务器后端中删除。
并且当订单中没有剩余物品时,也应将其从pageview.builder中删除,因为它也已从服务器中删除。
下面使用的代码是pageview.builder和list.viewbuilder小部件的
FutureBuilder(
future: _future,builder: (context,snapshot) {
switch (snapshot.connectionState) {
case ConnectionState.none:
return Text('none');
case ConnectionState.waiting:
return Center(child: CircularProgressIndicator());
case ConnectionState.active:
return Text('');
case ConnectionState.done:
if (snapshot.hasError) {
return Text(
'${snapshot.error}',style: TextStyle(color: Colors.red),);
} else {
return PageView.builder(
scrollDirection: Axis.horizontal,itemCount: snapshot.data.content.length,// length of total orders
itemBuilder: (context,index) {
var firstdata = jsonResponse['content'];
var list = firstdata[index]['order_items'];
return Column(
children:<Widget>[
Text( firstdata[index]['order_no]),ListView.builder(
shrinkWrap: true,itemCount: //lenght of the items in the order to be determined,itemBuilder: (context,index) {
return Column(
children: [
Text(list[index]['item_number']),RaisedButton(
onPressed: (){
callaction();
},)
],);
},),])
});
}
}
})
函数调用
callaction(){
print('action called on server');
var response = await http.post(url,body: data);
if (response.statusCode == 200) {
print('success');
}
}
请指导我如何实现所需的功能。 json flutter索引flutter-listview flutter-pageview
解决方法
您可以将QWaitCondition
的项目的索引传递给boost::condition_variable
。问题在于第二个构建器的索引在第一个构建器的阴影之下,因此您需要至少重命名两者之一。然后,您可以进行firstdata
,然后从callaction()
中删除正确的项目。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。