Skip to content

Assert if a transparent container absorbs hits #51000

Open

Description

@dnfield

This would be a behavior change, but I think I would find it confusing to have a transparent container absorbe hits. Today, Container(color: Colors.transparent) absorbs hits.

I'm marking this as stretch goals since it's not clear at this point if anyone is actually suffering because of this - if we find out it's causing confusion it shouldn't be too hard to fix though.

Activity

  1. added
    frameworkflutter/packages/flutter repository. See also f: labels.
    f: gesturesflutter/packages/flutter/gestures repository.
    on Feb 19, 2020
  2. added this to the milestone on Feb 19, 2020
  3. dnfield commented on Feb 19, 2020

    @dnfield
    ContributorAuthor

    That would be a major break. If that were to happen, this issue would be unnecessary.

    If we decide to do that, it should be not be to resolve this issue.

  4. dkwingsmt commented on Feb 19, 2020

    @dkwingsmt
    Contributor

    (Sorry for deleting my last reply, since I think I misunderstood the request.)

    Do you mean that this transparent container should not even prevent sibling objects behind it from being hit?

  5. dnfield commented on Feb 19, 2020

    @dnfield
    ContributorAuthor

    Today, this widget:

    Container(
      color: Colors.red,
      child: SizedBox(height: 50, width: 50),
    )

    Would first do hit testing on the child sized box. If the tap fell outside the sized box but still was inside the container, the container would return true from hitTest.

    I think that behavior is probably confusing in a fully-transparent colored container.

  6. dkwingsmt commented on Feb 19, 2020

    @dkwingsmt
    Contributor

    Can you explain the usage of this? Because I think it's more like a feature so that there is a way to absorb hits. Additionally we have to make sure all decorations are off to consider the container transparent, including color, image, border, shadow, etc, and not even a color with 1% alpha. On the other hand, you can always put the container inside the size box, isn't it?

  7. dnfield commented on Feb 19, 2020

    @dnfield
    ContributorAuthor

    We talked offline - my take at this point is that if we do anything about this, it's just add an assert. If a Container (or ColoredBox, or Decoration) gets a hitTestSelf request and its color is fully transparent, something is probably wrong - there's an invisible widget that is not an AbsorbePointer absorbing hits, and it's probably more expensive than just having an absorb pointer.

  8. changed the title [-]Consider making a transparent container/coloredbox/boxdecoration not participate in hit testing[/-] [+]Assert if a transparent container absorbs hits[/+] on Mar 9, 2020
  9. added
    P3Issues that are less important to the Flutter project
    on May 29, 2020
  10. removed this from the milestone on Aug 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Issues that are less important to the Flutter projectf: gesturesflutter/packages/flutter/gestures repository.frameworkflutter/packages/flutter repository. See also f: labels.team-frameworkOwned by Framework teamtriaged-frameworkTriaged by Framework team

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions