I have Page1 and Page2.
Page 1 is my base page and I am doing Navigator.push
for Page2. After finishing my logic in Page2, I will do Navigator.pop()
to return back to Page1.
How will I know that Page1 has become the main page visible to user?
I have tried ModalRoute.of(context).isCurrent
but I only want to know when Page2 has pop from Page1.
You can await
for the Page1
to finish and pass some data is required from the Page2
to make sure Page2
has been popped from the Navigator stack.
On Page1
bool result = await Navigator.push(context,..);
On Page2
Navigator.pop(context,"some data");
Then your result
will hold value "some data" if it's on the Page1
.You can similarly pass a boolean or other required data and compare it to know if the Page2
has been popped.