Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

The argument type 'MaterialPageRoute<dynamic>' can't be assigned to the parameter type 'String'

I am building a flutter app and I am trying to pass data to a page using MaterialPageRouter but I am getting an error that says "The argument type ‘MaterialPageRoute dynamic’ can’t be assigned to the parameter type ‘String’". Does anyone know what is this cause and please can anyone assist.

Here’s the code that is causing the error

                          onTap: () {
                            Navigator.pushNamed(
                                context,
                                MaterialPageRoute(
                                    builder: (context) =>
                                        ProductDetails(
                                            id: bottleCategory.bottleList[index].id,
                                            bottleName: bottleCategory.bottleList[index].bottleName,
                                            image: bottleCategory.bottleList[index].image,
                                            price: bottleCategory.bottleList[index].price)));
                          },

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You have to use Navigator.push, not Navigator.pushNamed

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading