akshathjain / sliding_up_panel

A draggable Flutter widget that makes implementing a SlidingUpPanel much easier!
https://pub.dartlang.org/packages/sliding_up_panel
Other
1.37k stars 378 forks source link

Too much widget rebuild occurring when using PanelBuilder #188

Open bananagag opened 4 years ago

bananagag commented 4 years ago

The PanelBuilder is rebuilding too often that it has affected the performance of the scrolling effect when the PanelBuilder's scroll controller is connected to its child widget. You can reference this bug to #94, this can be seen as the duplicate of #94, I am opening this issue only because the bug in that issue seems not fixed, but the topic is already closed.

Naxomiun commented 3 years ago

Any updates on this?

arafaysaleem commented 3 years ago

Try the following approach. This workaround might not stop the rebuilds but caches the child and fixes the scroll jank. What worked was, to store the widget inside the builder in a variable and return that variable from the builder.

var child;
return SlidingUpPanel(
  panelBuilder: (scrollController) {
    if(child == null) {
      child = SomeScrollableWidget();
    }
    return child;
  }
);
alus93 commented 1 year ago

For those of u who want a temporary solution .. Download the source code and make some changes by urself.

1 Keyboard trigger rebuild:

Wrap the first Stack of _SlidingUpPanelState within a LayoutBuilder Replace all entries in the source code (panel.dart) with MediaQuery.of(context)... with constraints.maxHeight/maxWidth

2 Scrolling trigger rebuild

Remove/Comment the setState of _onGestureSlide

I don't know which side effects these changes can have. For my purpose it worked.

CagriYonca commented 4 months ago

Try the following approach. This workaround might not stop the rebuilds but caches the child and fixes the scroll jank. What worked was, to store the widget inside the builder in a variable and return that variable from the builder.

var child;
return SlidingUpPanel(
  panelBuilder: (scrollController) {
    if(child == null) {
      child = SomeScrollableWidget();
    }
    return child;
  }
);

I've used this and worked. Please fix this issue.