rasitayaz / flutter-pie-menu

A Flutter package providing a highly customizable circular/radial context menu
https://rasitayaz.github.io/flutter-pie-menu/
MIT License
33 stars 18 forks source link

Exception in sliver_multi_box_adaptor #57

Closed Paroca72 closed 2 months ago

Paroca72 commented 5 months ago

Hello,

I'm using a ListView control with an exception when I add an element.

The exception is throw from sliver_multi_box_adaptor.dart

  @override
  double childMainAxisPosition(RenderBox child) {
    return childScrollOffset(child)! - constraints.scrollOffset;
  }

Exception: Null check operator used on a null value

On your library is generated on pie_menu_core.dart

                child: _theme.childBounceEnabled
                    ? BouncingWidget(
                        theme: _theme,
                        animation: _bounceAnimation,
                        pressedOffset:
                            _renderBox?.globalToLocal(_pressedOffset), // HERE!!!!!
                        child: widget.child,
                      )
                    : widget.child,

I seen the exception is thrown when _pressedOffset is (0, 0). Maybe is enough to check for empty values.

After the errors it is enough, for example, to close the keyboard to have the list rendered proper. So it seems have a phase in the redrawing that still have some widget properties still not set.

Thanks for your help Sam

Paroca72 commented 5 months ago

I changed this condition:

child: _theme.childBounceEnabled

to

child: _theme.childBounceEnabled && (_pressedOffset.dx != 0 && _pressedOffset.dy != 0)

And this solve my case

Thanks

rasitayaz commented 5 months ago

Can you provide a minimal reproducible example?