flutter-pie-menu
flutter-pie-menu copied to clipboard
Exception in sliver_multi_box_adaptor
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
I changed this condition:
child: _theme.childBounceEnabled
to
child: _theme.childBounceEnabled && (_pressedOffset.dx != 0 && _pressedOffset.dy != 0)
And this solve my case
Thanks
Can you provide a minimal reproducible example?