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.38k stars 381 forks source link

Too much widget rebuild occurring when using PanelBuilder [BETA] #94

Closed rohansohonee closed 4 years ago

rohansohonee commented 4 years ago

Hi @akshathjain

Just started playing around with the new PanelBuilder (beta) using this code snippet from your example docs:

// The sliding up panel
SlidingUpPanel(
      panelBuilder: (ScrollController sc) => _scrollingList(sc),
      body: Center(
        child: Text("This is the Widget behind the sliding panel"),
      ),
)
// The scrolling list
Widget _scrollingList(ScrollController sc) {
    print('scrolling list rebuilt');
    return ListView.builder(
      controller: sc,
      itemCount: 50,
      itemBuilder: (BuildContext context, int i) {
        return Container(
          padding: const EdgeInsets.all(12.0),
          child: Text("$i"),
        );
      },
    );
  }

Console log output for reference:

I/flutter ( 9831): scrolling list rebuilt
I/flutter ( 9831): scrolling list rebuilt
I/flutter ( 9831): scrolling list rebuilt
I/flutter ( 9831): scrolling list rebuilt
I/flutter ( 9831): scrolling list rebuilt
I/flutter ( 9831): scrolling list rebuilt

NOTE: When adding setState calls inside _scrollingList widget, it causes even more drastic performance issues as the widget gets rebuilt multiple times.

akshathjain commented 4 years ago

@rohansohonee I profiled the sample code and got render times at < 4 ms / frame which is substantially less than the 16 ms / frame that Flutter recommends to maintain 60 FPS.

However, it is unnecessary to rebuild the panelBuilder widget on each animation tick as the panel slides up and down (which is currently occurring). This will be resolved in the next update.

ozburo commented 4 years ago

@akshathjain just wanted to say that this update saved me! Got my Sliding Panel > PanelBuilder > CustomScrollView working like a charm!

Thanks 🥇

biklas7 commented 4 years ago

Hi, @akshathjain I'm having heavy performance problems with this. Glad to know you're working on it! Thanks for the awesome package :+1:

surveshoeb commented 4 years ago

@akshathjain have fixed this issue?

s0nerik commented 4 years ago

Looks like I've fixed it in https://github.com/akshathjain/sliding_up_panel/pull/112

akshathjain commented 4 years ago

Thanks to @s0nerik's PR, I'm closing this issue. This fix will be pushed to prod within the next 24 hours.

bananagag commented 4 years ago

Hi @akshathjain, I started to use this package recently and I found that the rebuilding issue is still there when using PanelBuilder with the scrollcontroller sc used as the child widget's controller (just like the sample code in this issue) and maybe you would like to consider reopening the issue. Thank you very much.

LarYoungruu commented 3 years ago

Hi @akshathjain Has this been fixed or not? I tried and found the problem is still there (2.0.0+1)

Screen Shot 2021-07-15 at 5 19 21 PM

mqhamdam commented 3 years ago

come here with the same problem. Cannot use panelbuilder with gridview. It rebuilds children on scroll max/min height

CagriYonca commented 6 months ago

Hi everyone,

I don't know why but the problem is still going on. I've used this solution as workaround and it worked, take a look: https://github.com/akshathjain/sliding_up_panel/issues/188#issuecomment-835254625