I am trying to pass a value to a Widget down the Navigator stack. Sample code:
class FirstPage extends StatefulWidget{
//...
receivedValue = await Navigator.push<String>(context, CupertinoPageRoute(
(ctx) => SecondPage(),
));
}
class SecondPage extends StatefulWidget{
//...
receivedValue = await Navigator.pushReplacement<String,String>(context, CupertinoPageRoute(
(ctx) => ThirdPage(),
));
}
class ThirdPage extends StatefulWidget{
//...
Navigator.pop<String>(context, outputString);
}
However the value is not passed to the first screen unless I keep the SecondPage in the stack. Reading the docs, there is a result property in pushReplacement that passes back to the previous screen in the navigator stack. In case of the replacing screen is popped.
However, the value I want to pass depends on user input in ThirdScreen. Is there a way to do it?