[Flutter] Navigator.pop 데이터 전달하기


[Flutter] Navigator.pop 데이터 전달하기

생각보다 간단하다! 우선 A 페이지에서의 버튼을 구현해보자 //A bool _state = false; ElevatedButton( onPressed: () async { bool state = await Navigator.push(context, MaterialPageRoute(builder: (context) => B())); setState(() { _state = state; }); }, ... ) 여기서 중요한건 async와 await 이다! B 페이지에서는 다음과 같이 구현하면 된다. ElevatedButton( onPressed: () { ... Navigator.pop(context, true); }, ... )


원문링크 : [Flutter] Navigator.pop 데이터 전달하기