Reputation: 139
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)));
},
Upvotes: 3
Views: 592
Reputation: 5736
You are passing a MaterialPageRoute
hence you need to use Navigator.push
, not the Navigator.pushNamed
.
Navigator.pushNamed
is for using named routes.
Upvotes: 8