Home > Software engineering >  inkwell onTap is not working inside container
inkwell onTap is not working inside container

Time:08-05

i'm trying to make a gallery app. i want a picture to open individually when tapped. but when I tap on a picture inkwell animation occurs but the new page doesn't open. i have defined second page in routes Here is the code of landing page

class _ImageViewState extends State<ImageView> {
  @override
  Widget build(BuildContext context) {
    return Container(
        child: PhotoView(
          maxScale: 600.0,
          minScale: 200.0,
          imageProvider: AssetImage("assets/mountain1.jpg",),
        )
    );
  }
}

and this is the code where I'm calling the above class

child: InkWell(
                          onTap: () => {const ImageView()},
                        child: Image.asset('assets/mountain1.jpg', fit: BoxFit.fill,)),

CodePudding user response:

Inside

OnTap method

you can only add functionality things, you can't load widget like that. if you try to load.

Or please provide more information here.

CodePudding user response:

this is how you can open new page

Navigator.push(
    context,
    MaterialPageRoute(builder: (context) => const ImageView()),
);
  • Related