I am running into a problem which I find difficult to describe.
I have a class with two variables. On page 1, I would like to show variable 1. Then, if the user progresses to page 2, I would like to display a widget with variable 1 and 2. I understood how to pass data from one screen to another, but how would I progress if I had to get more data one the second page.
This is the class:
class Dog {
String name;
String age;
Dog({ this.name, this.age });
}
On the first page, I only define the String name, but not the age. Hence, when the user progresses to the second page, I pass the name data as follows (from a list of dogs):
Navigator.push(context,
MaterialPageRoute(
builder: (context) => Screen2(dog: dogs[index]),
),
);
On the second screen, I would like to show a statelesswidget with both class variables, but I only passed one:
final Dog dog;
Screen2({Key key, @required this.dog}) : super(key: key);
In the last code, "this.dog" only includes the name String.
How could I now add the age String as well? Do I have to add it to Navigator.push, or is there a way to add it in the statelesswidget?
Thanks so much in advance for any guidance you can give me!