[英]Flutter FutureBuilder not reloading after add new record
I have a customer crud with listview page populated with futurebuilder that loads customer data from database and another page to insert/edit new customers. 我有一个客户列表,其中的listview页面填充有futurebuilder,该页面从数据库中加载客户数据,另一个页面用于插入/编辑新客户。
I want to reload the listview after insert or edit a customer and go back to listview page by tapping back button. 我要在插入或编辑客户后重新加载列表视图,然后通过单击“后退”按钮返回到列表视图页面。
I've tried RouteObserver didPop and didPopNext but without success. 我已经尝试过RouteObserver didPop和didPopNext,但是没有成功。
Listview page code Listview页面代码
Has anyone had a similar problem? 有人遇到过类似的问题吗?
When you call the other page with Navigator
you can await the result and do whatever you want with it. 当您使用Navigator
调用另一个页面时,您可以等待结果并对其执行任何操作。
Cliente clienteEditado = await Navigator.push(context, MaterialPageRoute<Cliente>(builder: (context) => Editar(cliente: clientes[index])));
clientes[index] = clienteEditado;
setState(() {});
To receive the cliente above you do the following in the editing page: 要接收上述客户,请在编辑页面中执行以下操作:
onPressed: () {
_save();
Navigator.pop(context, widget.cliente);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.