Reputation: 11
I'm facing an issue regarding API datas, I want the pass the texts, Image generated by API to another screen screen
Here is the
String _name(dynamic user){
return user['name']['title'];
}
String _description(dynamic user){
return user['name']['description'];
}
I want to pass these texts to the next screen using Provider or MaterialRoute Page, How can I do so in a real example
Thanks
Upvotes: 0
Views: 362
Reputation: 2531
You can do this by 2 ways:
class SecondScreen extends StatelessWidget {
final String title;
final String description;
SecondScreen(this.title, this.description);
}
And in routing:
Navigator.push(
context,
MaterialPageRoute(builder: (context) => SecondScreen(title, description)),
);
A Provider basically allows you to access data belonging to class from any widget. Here is a link to the Provider package. You'll find examples over there.
Upvotes: 2