Reputation: 73
I want to send boolean to my other page when i pop from specific screen let's call it Screen2 and my main screen is Screen1,
Screen3
bool data=true;
Navigator.of(
context,
).popUntil((_) => count++ >= 2);
Screen2
User will push from first Screen1 to Screen2 then Screen2 to Screen3 then pop back from Screen3 to Screen1
Screen1
bool isScreen1PoppedFromScreen2(data){
if(data)
return true;
else{
return false;
}
}
is there anyway to do it without using Navigator.push, or Navigator.pushNamed ?
Upvotes: 0
Views: 478
Reputation: 2282
While popping from your second screen you can
Navigator.pop(context, true);
And in first screen you can navigate to 2nd one like
final result =Navigator.push(
context,
MaterialPageRoute(builder: (context) => SecondRoute()),);
now you can use the 'result' as boolean variable to check whether navigated or not.(When you will pop the second screen then the value of result will become true i.e you have popped the second screen)
Upvotes: 1