Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dismiss bottom sheet when scrolling inner scrollable down

Tags:

flutter

I'm having Flutter's full screen modal bottom sheet which has SingleChildScrollView inside it.

Normal outcome is that whether I scroll up or down, it scrolls inner scrollable. I can close modal bottom sheet by dragging down anything that is outside the scrollable (it's a small container with a drag handle in it for me).

The issue is that I want to pull down bottom sheet if I am pulling down inner scrollable. After doing some research, I've found that I should operate with AlwaysScrollableScrollPhysics and NeverScrollableScrollPhysics but I really can't find the best solution here.

My idea is that inner scrollable is allowed to scroll until it's scroll offset is negative. That doesn't work since I need some way to make it scrollable when I stop scrolling without closing bottom sheet.

I could wrap inner scrollable into GestureDetector and checking against the scrolling delta but no success yet.

Maybe anyone have had a similar issue and got some example or algorithm?

like image 730
dpitkevics Avatar asked Sep 07 '19 16:09

dpitkevics


People also ask

How do I use SingleChildScrollView inside column in flutter?

The following code illustrates this. Widget build(BuildContext context) => Scaffold( body: Column( children: <Widget>[ Container( height: 100.0, color: Colors. blue, ), Expanded( child: SingleChildScrollView( child: Container( color: Colors. red, padding: EdgeInsets.


1 Answers

Add modal_bottom_sheet and use showMaterialModalBottomSheet

showMaterialModalBottomSheet(
                          context: context,
                          builder: (context) {
                            return SingleChildScrollView(
                              child: Column(
                                children: [
                                  Container(
                                    width: MediaQuery.of(context).size.width,
                                    height: MediaQuery.of(context).size.height * 0.8,
                                    color: Colors.green,
                                  ),
                                  Container(
                                    width: MediaQuery.of(context).size.width,
                                    height: MediaQuery.of(context).size.height * 0.8,
                                    color: Colors.red,
                                  ),
                                ],
                              ),
                            );
                          });
like image 149
Miftakhul Arzak Avatar answered Nov 10 '22 22:11

Miftakhul Arzak