I created a loop to print articles (with their title, and their content). I made the row containing these infos, clickable. But I need help so when I click on the text, I am redirected on another page which will display the title the full text. In conclusion i want to send the data (title and description) on another page that varies depending on the article i clicked on.
Would really appreciate your help!
CodePudding user response:
you can pass title and content as arguments, something like this:
class ArticlePage extends StatelessWidget {
final String title;
final String content;
const ArticlePage({
super.key,
required this.title,
required this.content,
});
@override
Widget build(BuildContext context) {
/// use title and content
}
}
and navigator:
Navigator.of(context).push(
MaterialPageRoute(
builder: (_) => const ArticlePage(
title: 'your title',
content: 'your content',
),
),
);