1

I want to open a detail page from a list view and not sure how to pass the value of the title clicked to other page

GoRoute(
  path: "/detailed_post/:title/:description",
  builder: (context, state) => DetailedPost(
    questionTitle: state.params['title']!,
    ),
  ),


class PostCard extends StatefulWidget {
  const PostCard({super.key, required this.title});
  final String title;

  @override
  State<PostCard> createState() => _PostCardState();
}


onTap: () {    
  GoRouter.of(context)
            .go('/detailed_post/...);
      },

What should I put in the ... instead, thanks

ngqh
  • 33
  • 3

1 Answers1

2

you can do this trick:

onTap: () {    
/// adding 
  GoRouter.of(context)
    .go('/detailed_post/${widget.title}/...');
},

and in DetailedPost you can retrieve the value of your title parameter from state.params['title'].

happy coding...

Amirali Eric Janani
  • 1,477
  • 3
  • 10
  • 20