Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class FirstPage extends StatelessWidget{
- final String firstText;
- FirstPage(this.firstText);
- Widget build(BuildContext context){
- return RaisedButton(onPressed: (){
- firstText = "Hello World";
- Navigator.of(context).push(SecondPage(secondText: firstText); //The firstText value is now passed to SecondPage class
- }
- }
- class SecondPage extends StatelessWidget{
- final String secondText;//instantiate
- SecondPage(this.secondText);//constructor
- Widget build(BuildContext context){
- return Text(seconText);//will have the value of "firstText" which is "hello world"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement