简体   繁体   中英

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.

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.

Listview page code

Edit page code

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.

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);
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM