If I understand this correctly, you have a ListView with multiple children. When the user pressed, or taps, on an item, you want to push an edit ui/page with the current item as data for the page, then when the user is done editing, you want to pop the edit ui, and then re-open it with the next item from your ListView.
So basically you have a ItemsUi and a EditItemUi. The clean way to handle this is from the ItemsUi, not the EditItemUi. Here is the code, and the explanation after it:
// ItemsUi
final items = [//your items];
.....
@override
Widget build(BuildContext context) {
ListView.builder(itemBuilder: (context, index) => ListTile(title: items[index].name, onTap: () => onItemTap(index),)
....
onItemTap(index) async {
if(index >= items.length) return;
final result = await Navigator.push(
context,
MaterialPageRoute(
builder: (context) => EditItemUi(items[index]),
),
);
onItemTap(++index);
}
_processResult(result) { // process result}
In your onTap function, you should keep the index of the item, and then await the result. Once you have the result, just call the same method recursively on the next item, and so on.
PS: PLEASE don't pass the buildContext as a result in Navigator.pop(result). This will make you run down a rabit hole of errors.
ListView.builderto make it easier to provide an answer for your usecase.