in ,

A Flutter widget for Scrollview, pop when overscroll like Instagram

scroll widget

If you have used Instagram or Pinterest, you can see that when you scroll up, the toolbar will push up and be replaced by the header of the feed. 

When you continue to scroll, the header of the second feed will push up and replace the header of the first. 

This is a useful and convenient function for users when they use it. So how can they do that? What kind of widgets support them? In this tutorial, I will show you a widget for Scrollview, pop when overscroll like Instagram, Pinterest.  With beautiful interface, it will brings a good experience.

This is a widget for Scrollview, pop when overscroll and it like Instagram, Pinterest:

flutter widget

Please go to the next steps to complete the installation and usage procedures.

Getting Started

  1. Include the package to your project as dependency:
  	overscroll_pop: <latest version>

  1. Use the widget:

Wrap your Scaffold or top widget by OverscrollPop, every ScrollView widget (ListviewGridViewPageViewCustomScrollView, …) which has scroll physics ClampingScrollPhysics(important) will have overscroll to pop effect.

      home: Scaffold(
        appBar: AppBar(
          title: const Text('Overscroll Example'),
        body: Builder(
          builder: (c) => Center(
            child: Hero(
              tag: '${ScrollToPopOption.start}${DragToPopDirection.toRight}',
              child: ElevatedButton(
                onPressed: () => pushPage(
                  (BuildContext context, _, __) => VerticalScrollview(
                    scrollToPopOption: ScrollToPopOption.start,
                    dragToPopDirection: DragToPopDirection.toRight,
                child: Text('Vertical scrollview ${ScrollToPopOption.start}'),

    class VerticalScrollview extends StatelessWidget {
      final ScrollToPopOption scrollToPopOption;
      final DragToPopDirection? dragToPopDirection;

      const VerticalScrollview({
        Key? key,
        this.scrollToPopOption = ScrollToPopOption.start,
      }) : super(key: key);

      Widget build(BuildContext context) {
        return OverscrollPop(
          scrollToPopOption: scrollToPopOption,
          dragToPopDirection: dragToPopDirection,
          child: Container(
            clipBehavior: Clip.hardEdge,
            decoration: BoxDecoration(borderRadius: BorderRadius.circular(16.0)),
            child: Scaffold(
              appBar: PreferredSize(
                preferredSize: Size.fromHeight(kToolbarHeight),
                child: Hero(
                  tag: '$scrollToPopOption${dragToPopDirection ?? ''}',
                  child: AppBar(
                    title: Text(
                      'Vertical Scrollview',
                      overflow: TextOverflow.visible,
              body: ListView.builder(
                physics: const ClampingScrollPhysics(),
                itemBuilder: (_, index) => Container(
                  height: 160.0,
                  margin: const EdgeInsets.symmetric(vertical: 8.0),
                  color: index % 2 == 0 ? Colors.cyanAccent : Colors.orangeAccent,
                  child: Column(
                    children: [
                      if (dragToPopDirection != null)
                itemCount: MediaQuery.of(context).size.height ~/ 160.0 + 2,

  1. Configure scroll direction and add extra drag to pop:
    • By default, the effect only apply for overscroll at the start of ScrollView (top edge of vertical scroll, left edge of horizontal scroll)
- To enable the end edge (or both edges) for overscroll to pop, set `scrollToPopOption` to `ScrollToPopOption.end` (or `ScrollToPopOption.both`)
      scrollToPopOption: ScrollToPopOption.end, // or ScrollToPopOption.both

- Beside overscroll, you can config the other drag direction to achieve the pop effect by passing `dragToPopDirection`
      dragToPopDirection: DragToPopDirection.toTop, //  toTop, toBottom, toLeft, toRight, horizontal and vertical

  1. Vertical scroll: drag to left, right or horizontal (both left and right)
  1. Horizontal scroll: drag to top, bottom or vertical (both top and bottom)


Written by James

A flutter navigation by gestures and taps

A scrolling digital animation widget for flutter