Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nested ScrollView inside Slidable panel widget

Tags:

flutter

I have a panel widget that can be dragged vertically in and out from the bottom of the screen. In that panel widget, there is a ListView that is scrollable.

What I'm trying to achieve is, having the panel handle the drag for opening and closing without the nested listview interfering. Once, the panel is open, the listview become scrollable and if the listview is scrolled down while already at the top, the panel handle the gesture instead and closes.

Like so:

enter image description here

I tried to enable/disable scrolling physics on the ListView based on the Panel position but turned out not to be possible that way.

Any ideas ? :)

like image 213
Théo Champion Avatar asked Oct 22 '19 20:10

Théo Champion


People also ask

How do you make nested scrollView in flutter?

Scrolling in Flutter The simplest one is to use the SingleChildScrollView widget that automatically scrolls its child when needed. You have other options as well, like ListView or GridView to display multiple elements. Both widgets provide constructors that require a builder method to build their children on demand.

What is nested scrollView?

NestedScrollView is just like ScrollView , but it supports acting as both a nested scrolling parent and child on both new and old versions of Android. Nested scrolling is enabled by default.

How do I prevent NestedScrollView from scrolling if body is small?

The problem can be solved by moving the SliverAppBar into the CustomScrollView and not use the NestedScrollView at all.

How do I stop NestedScrollView scrolling?

setnestedscrollingenabled set it to false. try this one add property in recyclerview android:descendantFocusability="blocksDescendants" .


1 Answers

You can achieve that with DraggableScrollableSheet.

Here is a quick example of how you can use it:

@override
Widget build(BuildContext context) {
  return Scaffold(
    body: Stack(
      children: <Widget>[
        Center(child: Text('Some content')),
        DraggableScrollableSheet(
          minChildSize: 0.2,
          initialChildSize: 0.2,
          builder: (context, scrollController) => Container(
            color: Colors.lightBlueAccent,
            child: ListView.builder(
              controller: scrollController,
              itemCount: 20,
              itemBuilder: (context, index) => SizedBox(
                height: 200,
                child: Text('Item $index'),
              ),
            ),
          ),
        ),
      ],
    ),
  );
}
like image 170
Pablo Barrera Avatar answered Oct 11 '22 19:10

Pablo Barrera