Flutter 刷新Navigator.pop函数的上一页

Flutter 刷新Navigator.pop函数的上一页,flutter,Flutter,调用Navigator.pop(context)时,是否有方法刷新上一页/堆栈?我需要调用上一页的API来刷新页面的状态。navigator.pop有时是一个警告对话框,也可能是一个后退按钮。有没有办法进行API调用?谢谢。上一页 void goToNextPage()async { var refresh = await Navigator.push(_context, new MaterialPageRoute( builder: (BuildContext context) =>

调用Navigator.pop(context)时,是否有方法刷新上一页/堆栈?我需要调用上一页的API来刷新页面的状态。navigator.pop有时是一个警告对话框,也可能是一个后退按钮。有没有办法进行API调用?谢谢。

上一页

void goToNextPage()async {

 var refresh = await Navigator.push(_context, new MaterialPageRoute(
 builder: (BuildContext context) => new nextPage(context))
 );
if(refresh ) setState((){});

}
Navigator.pop(context, true);
NextPage

void goToNextPage()async {

 var refresh = await Navigator.push(_context, new MaterialPageRoute(
 builder: (BuildContext context) => new nextPage(context))
 );
if(refresh ) setState((){});

}
Navigator.pop(context, true);

按下另一条路线后,使用
然后
功能

Navigator.of(context).push(
  MaterialPageRoute(
    builder: (context) => MyHomePage(),
  ),
).then(
  (value) {
    if (value) {
      //refresh here
    }
  },
);
当您返回上一屏幕时,为
pop
函数提供一个确定是否执行某些操作的值

Navigator.of(context).pop(true);

谢谢你!!我应该在“刷新此处”部分添加什么?您可以调用API并更改状态。