Skip to content

Make ListView scrollable within PageView  #50946

Open
@altherat

Description

@altherat

Unless I'm missing something, I don't believe it's possible to achieve scrolling on both a ListView (or SingleChildScrollView) and a PageView when the ListView is within the PageView and they both scroll in the same direction.

Consider the following simple example app with a vertical scrolling ListView within a vertical PageView:

void main() => runApp(App());

class App extends StatelessWidget {

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(),
        body: PageView(
          scrollDirection: Axis.vertical,
          children: <Widget>[
            ListView.builder(
              itemCount: 20,
              itemBuilder: (BuildContext context, int index) => ListTile(title: Text('Item $index'))
            ),
            Text('Page 2')
          ],
        )
      )
    );
  }

}

There is no way to get the PageView to scroll pages. I think expected behavior should be that when the ListView is scrolled to the bottom, the PageView should then handle the gesture. If I remember correctly, I believe it works like this with Android's RecyclerView and ViewPager.

I've played around with ScrollPhysics, ScrollBehavior, and NotificationListener such as listening for OverscrollNotification and then disabling scrolling for ListView, but I could not find a solution that worked well.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Issues that are less important to the Flutter projectc: proposalA detailed proposal for a change to Flutterf: gesturesflutter/packages/flutter/gestures repository.f: scrollingViewports, list views, slivers, etc.frameworkflutter/packages/flutter repository. See also f: labels.team-frameworkOwned by Framework teamtriaged-frameworkTriaged by Framework team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions