Skip to content

Tap/Click detector is bugged within Stack widget #20798

@shtengel

Description

@shtengel

I Have a problem with the Stack Widget.
I have a Stack that contains two children: an Image wrapped with InkWell and an IconButton.
When i click anywhere on the image, whoever is last on the Stack children list his onTap/onPressed callbacks is executed. even if i click the image and not the iconbutton, the iconbutton's onPressed is called.
how can i correct this?
My goal is to have an Image with an 'X' icon button on the right corner.

Stack(
                fit: StackFit.expand,
                children: <Widget>[
                  InkWell (
                    onTap: () {
                      setState(() {
                        // Not Called
                      });
                    }, child :new Image(
                    height: 60.0,
                    width: 60.0,
                    image: new NetworkImage("SomeImageURL"),
                    fit: BoxFit.fill,
                  )),
                  IconButton(
                    color: Theme.of(context).accentColor,
                    alignment: Alignment.topRight,
                    icon: Icon(Icons.cancel),
                    onPressed: () {
                      setState(() {
                        // Called even if i click the image and not the tiny IconButton which is on top
                      });
                    },
                  )
                ],
              )

Metadata

Metadata

Assignees

No one assigned

    Labels

    in triagePresently being triaged by the triage teamwaiting for customer responseThe Flutter team cannot make further progress on this issue until the original reporter responds

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions