Advertisement
Guest User

Untitled

a guest
Aug 21st, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 0.56 KB | None | 0 0
  1. class FirstPage extends StatelessWidget{
  2. final String firstText;
  3. FirstPage(this.firstText);
  4.  
  5. Widget build(BuildContext context){
  6. return RaisedButton(onPressed: (){
  7.     firstText = "Hello World";
  8.     Navigator.of(context).push(SecondPage(secondText: firstText); //The firstText value is now passed to SecondPage class
  9.     }
  10. }
  11.  
  12. class SecondPage extends StatelessWidget{
  13. final String secondText;//instantiate
  14. SecondPage(this.secondText);//constructor
  15.  
  16. Widget build(BuildContext context){
  17. return Text(seconText);//will have the value of "firstText" which is "hello world"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement