Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BubbleShowcase doesn't work well with FittedBox #7

Open
ma-ruz opened this issue Jul 1, 2020 · 0 comments
Open

BubbleShowcase doesn't work well with FittedBox #7

ma-ruz opened this issue Jul 1, 2020 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@ma-ruz
Copy link

ma-ruz commented Jul 1, 2020

Describe the bug
When I use BubbleShowcase with a RelaitveBubbleSlide with a key that identifies a widget inside a FittedBox, the shape is not displayed in correct size. It looks like the FittedBox's resizing is not taken into consideration.

To Reproduce
Steps to reproduce the behavior:

  1. Use something like this in your app:
  BubbleShowcase(...,
      bubbleSlides: [RelativeBubbleSlide(
              widgetKey: _resizedWidgetKey,
              shape: Oval(),
              child: MyRelativeBubbleSlideChild(...)
          )],
      child: ...(FittedBox(child: ...(Text('Hello', key: _resizedWidgetKey))))

  1. Run the app and let the slides show.
  2. See that the oval shape displays wrongly sized (and the slide child is wrongly positioned).

Expected behavior
The FittedBox should affect the size of the slide shape.

For myself, I have fixed this by creating a subclass of RelativeBubbleSlide that converts not only the top left corner from local to global coordinates, but the bottom right as well. The code looks like this:

  Position getHighlightPosition(BuildContext context, BubbleShowcase bubbleShowcase, int currentSlideIndex) {
    RenderBox renderBox = widgetKey.currentContext.findRenderObject() as RenderBox;
    Offset offset = renderBox.localToGlobal(Offset.zero);
    Offset bottomRight = renderBox.localToGlobal(renderBox.size.bottomRight(Offset.zero)); // convert the bottom right corner from local to global coordinates

    return Position(
      top: offset.dy,
      right: bottomRight.dx, // instead of adding the local size to the global offset use the global coordinates of bottom right corner
      bottom: bottomRight.dy, // instead of adding the local size to the global offset use the global coordinates of bottom right corner
      left: offset.dx,
    );
  }

@ma-ruz ma-ruz added the bug Something isn't working label Jul 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants