1

I have created website using flutter and I am left with one last details. The website is webshop and has products. I wish to access products from url like this "url.com/product?id=3", it should return product with id 3.

I have created the app that works well with it but only if I hardcode id. I can't figure it out how to catch it. I am using named routines and the links display nice and I can pretty much navigate using links, but i cannot open products with links.

Code so far is

class ProductPage extends StatefulWidget {
  ProductPage({Key? key, required this.id}) : super(key: key);

  int id;

  @override
  State<ProductPage> createState() => _ProductPageState();
}

and named route being

 '/product': (context) =>
            Manager().userType() == "M" || Manager().userType() == "A"
                ? ModProductPage(id: 9)
                : ProductPage(id: 8)
  • Possible duplicate of https://stackoverflow.com/questions/57552885/how-can-a-named-route-have-url-parameters-in-flutter-web – Richard Heap Jun 02 '22 at 01:05

0 Answers0