Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bottomSheet is always rebuild #21

Closed
klaszlo8207 opened this issue Mar 11, 2020 · 3 comments
Closed

bottomSheet is always rebuild #21

klaszlo8207 opened this issue Mar 11, 2020 · 3 comments

Comments

@klaszlo8207
Copy link

I have a

Get.bottomSheet(
isScrollControlled: true,
builder: (_) => MySheetWidget(title));

MySheetWidget is a statefulwidget

When i move the sheet top/bottom the build method always triggering

@klaszlo8207
Copy link
Author

Sorry I did it:

builder: (_) => MySheetWidget(title));

instead of, better:

final page = MySheetWidget(title));

builder: (_) => page;

@klaszlo8207
Copy link
Author

klaszlo8207 commented Apr 17, 2020

Sorry I reopen it.

I need that the bottomSheet no rebuild when I resize it. (builder is always build when scrolling)

I want to control when I want to rebuild the bottomsheet

Any way to do that?

@jonataslaw
Copy link
Owner

jonataslaw commented Apr 18, 2020

Please ask support questions on appropriate channels like stackoverflow.
Get just opens the BottomSheet with the overlayContext.
You can even use default Flutter's bottomsheet with Get.overlayContext

 showModalBottomSheet(
      context: Get.overlayContext, // rather context
      builder: (BuildContext bc){
          return Container(
            child: new Wrap(
            children: <Widget>[
        ListTile(
            leading:  Icon(Icons.music_note),
            title:  Text('Music'),
            onTap: () => {}          
          ),
           ListTile(
            leading:  Icon(Icons.videocam),
            title:  Text('Video'),
            onTap: () => {},          
          ),
          ],
          ),
        );
      }
    );

So, your issue is not a bug description or a resource request, and I can't help you here.

Put your question on the stackoverflow and I can answer you there.

I just make it clear here, that the bottomsheet is rebuilt with each dragged pixel. You cannot change this behavior, because without the reconstruction, it would not change in size (it is the size change that causes the reconstruction), so if there is any side effect to this, the problem is in the logic of your code.

Advices:

1- Always create a Stateful widget, and call the bottomsheet with it inside:

Get.bottomsheet(builder: (_) => const YourStatefulClass());

2- Use Stateful, never Stateless if you want something to remain in a state. Never place controllers inside the build method, but at the beginning of the class.

3- Use const in the class builder, and call your class const, this will totally prevent your child widget from being rebuilt when the parent (bottomsheet) is rebuilt.

If you have questions related to the library, (and not when Flutter widgets work), do not hesitate to open another issue.
Closing by offtopic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants