简体   繁体   中英

Stop scrolling in DraggableScrollableSheet in flutter

I would like to stop the inside of my DraggableScrollableSheet from scrolling while still being able to drag it up and down. Is there a way to do that? I've used a bottomSheet but they were unable to be dragged up and down.

I'd like to stay away from third party code, so if there is a way to do it natively that would be amazing. Here's an example of what is currently happening:

在此处输入图像描述

Here is my relevant code:

@override
Widget build(BuildContext context) {
    return Scaffold(
        drawer: SettingsDrawer(username: _username),
        body: Stack(
            children: <Widget>[
                MapWidget(),
                MenuButton(),
                DraggableScrollableSheet(
                    initialChildSize: 0.35,
                    minChildSize: 0.2,
                    maxChildSize: .35,
                    builder: (BuildContext context, ScrollController scrollController) {
                         return SingleChildScrollView(
                           controller: scrollController,
                           child: HelpSheet(),
                         );
                   },
                )
            ]
        ),
    );
}

I decided to go with SlidingUpPanel instead of trying to to it natively.

SlidingUpPanel(
    maxHeight: 350.0,
    minHeight: 150.0,
    parallaxEnabled: true,
    parallaxOffset: .1,
    panel: HelpSheet(),
    borderRadius: BorderRadius.only(
    topLeft: Radius.circular(18.0),
    topRight: Radius.circular(18.0)
),

You can try by adding NeverScrollableScrollPhysics() to SingleChildScrollView as follows,

...    

return SingleChildScrollView(
  physics: NeverScrollableScrollPhysics(),
  controller: scrollController,
  child: HelpSheet(),
);

...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM