flutter-pie-menu icon indicating copy to clipboard operation
flutter-pie-menu copied to clipboard

Exception in sliver_multi_box_adaptor

Open Paroca72 opened this issue 1 year ago • 2 comments

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 avatar May 24 '24 02:05 Paroca72

I changed this condition:

child: _theme.childBounceEnabled

to

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

And this solve my case

Thanks

Paroca72 avatar May 24 '24 03:05 Paroca72

Can you provide a minimal reproducible example?

rasitayaz avatar Jun 20 '24 17:06 rasitayaz