A Flutter widget for Scrollview, pop when overscroll

Overview

overscroll_pop

A Flutter widget for Scrollview, pop when overscroll like Instagram, Pinterest, ...

Demo Demo Demo

Getting Started

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

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

    MaterialApp(
      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(
                  c,
                  (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,
        this.dragToPopDirection,
      }) : super(key: key);

      @override
      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,
                  alignment: Alignment.center,
                  child: Column(
                    mainAxisAlignment: MainAxisAlignment.center,
                    children: [
                      Text(scrollToPopOption.toString()),
                      if (dragToPopDirection != null)
                        Text(dragToPopDirection.toString()),
                    ],
                  ),
                ),
                itemCount: MediaQuery.of(context).size.height ~/ 160.0 + 2,
              ),
            ),
          ),
        );
      }
    }

If your Scaffold does not contain any ScrollView and want to achieve drag to pop effect, wrap your Scaffold or top widget by DragToPop instead (Example).

Quick push route config helper:

pushOverscrollRoute(
    context: context,
    child: <your scaffold/widget>,
    // scrollToPopOption: <your ScrollToPopOption>,
    // dragToPopDirection: <your DragToPopDirection>,
    // other route configs
)

pushDragToPopRoute(
    context: context,
    child: <your scaffold/widget>,
    // other route configs
)
  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)

      VStart HStart

    • To enable the end edge (or both edges) for overscroll to pop, set scrollToPopOption to ScrollToPopOption.end (or ScrollToPopOption.both)

      OverscrollPop(
        scrollToPopOption: ScrollToPopOption.end, // or ScrollToPopOption.both
        ...
      )
      

      VEnd HEnd

    • Beside overscroll, you can config the other drag direction to achieve the pop effect by passing dragToPopDirection

      OverscrollPop(
        dragToPopDirection: DragToPopDirection.toTop, //  toTop, toBottom, toLeft, toRight, horizontal and vertical
        ...
      )
      
      1. Vertical scroll: drag to left, right or horizontal (both left and right) VStartToLeft VStartToLeft

      2. Horizontal scroll: drag to top, bottom or vertical (both top and bottom) HEndToTop HEndToBottom

Comments
  • pop without scroll view

    pop without scroll view

    Hi @luunc thanks for this great library and the nice gif representations. I want to ask why you are limiting the package to only be used in scroll views? For instance I want to use this package for stories just like in instagram. Sometimes they are only one story videos and the user needs to be able to dismiss/pop them towards the direction of their finger (not towards one of the 4 up, down, left, right) Do you think it is a good idea?

    enhancement 
    opened by aytunch 8
  • Fade Container behind DrapToPop widget moves while page is being popped

    Fade Container behind DrapToPop widget moves while page is being popped

    The semi transparent Container moves down once the DragToPop widget is popped. This makes unwanted edge seen through out the animation.

    https://user-images.githubusercontent.com/6442915/120933967-24237700-c705-11eb-9386-883198fce18c.mov

    IMG_4703

    opened by aytunch 1
  • enabled property

    enabled property

    I have a Camera Page that sometimes I push and sometimes I use as a widget in a PageView

    If there is an enabled bool property for DragToPop, I could set it accordingly and only allow the page to be dragged if it was pushed. If enabled is false, the DragToPop widget would have no effect.

    This would allow us to reuse the page without using big if else blocks.

    Do you think this is useful? Thanks

    opened by aytunch 0
  • Exception caught by gesture

    Exception caught by gesture

    Hi @luunc, Sometimes I get an error like this while page is being popped. Is this caused by the package or by me? Thanks for this awesome widget by the way :D

    ════════ Exception caught by gesture ═══════════════════════════════════════════ The following _CastError was thrown while handling a gesture: Null check operator used on a null value

    When the exception was thrown, this was the stack #0 _DragToPopState._onDragUpdate package:overscroll_pop/drag_to_pop.dart:104 #1 ScaleGestureRecognizer._advanceStateMachine. package:flutter/…/gestures/scale.dart:494 #2 GestureRecognizer.invokeCallback package:flutter/…/gestures/recognizer.dart:182 #3 ScaleGestureRecognizer._advanceStateMachine package:flutter/…/gestures/scale.dart:493 #4 ScaleGestureRecognizer.handleEvent package:flutter/…/gestures/scale.dart:389 ... Handler: "onUpdate" Recognizer: ScaleGestureRecognizer#fb388 debugOwner: GestureDetector ════════════════════════════════════════════════════════════════════════════════

    opened by aytunch 0
  • Background during Overscroll animation is black.

    Background during Overscroll animation is black.

    Hi, great package, thanks. Unfortunately the page from which the hero is pressed gets lost during the overscroll animation ( => black, see video). Any idea what's happening? Sth about the routes? (I suppose you don't need to see the code snippet).

    Thanks in advance!

    Screen-Recording-2022-01-10-at-14 07 45

    opened by fior-di-latte 0
  • Can we have a non full screen page and pop it?

    Can we have a non full screen page and pop it?

    Hi @luunc In our requirements we have a page which takes half of the height of the screen. In this page there is long content so it is scrollable. Can I use this package to push and pop it vertically(only downwards) and still keep the inner scrolling behavior?

    opened by aytunch 0
Owner
null
This example uses a ScrollView, JSON Rest API, Navigation, Alert Pop Up, Progress Indicator, Globals, Images in a shared asset folder, and 100% Shared Code

This example uses a ScrollView, JSON Rest API, Navigation, Alert Pop Up, Progress Indicator, Globals, Images in a shared asset folder, and 100% Shared Code. Now with the ability to login with FaceID, TouchID, and Fingerprint Reader on Android.

Rody Davis 672 Jan 6, 2023
A powerful official extension library of Tab/TabBar/TabView, which support to scroll ancestor or child Tabs when current is overscroll, and set scroll direction and cache extent.

extended_tabs Language: English | 中文简体 A powerful official extension library of Tab/TabBar/TabView, which support to scroll ancestor or child Tabs whe

FlutterCandies 185 Dec 13, 2022
Peek & Pop implementation for Flutter based on the iOS functionality of the same name.

peek_and_pop Peek & Pop implementation for Flutter based on the iOS functionality of the same name. Finally, the v1.0.0 release! More fluent, more opt

AliYigitBireroglu 227 Dec 17, 2022
A page transition which supports drag-down-to-pop gesture.

drag_down_to_pop A page transition which supports drag-down-to-pop gesture. The main source code is copied from the cupertino/route.dart in Flutter SD

nekocode 16 Aug 6, 2022
best flutter / dart practices + Custom Painter + Sliver App Bar + Custom Scrollview

Weekly Budget Flutter App A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get yo

Mohamed Awnallah 4 Oct 21, 2021
Flutter Scrollable Widgets like ListView,GridView or powerful CustomScrollView can't nest inner scrollview

Introduction Flutter Scrollable Widgets like ListView,GridView or powerful CustomScrollView can't nest inner scrollview. If Nested, inner scrollview w

jaysonss 5 Aug 28, 2022
A wrapper for a Flutter ScrollView which enables lazy loading

Lazy load scrollview A wrapper for a ScrollView that will enable lazy loading Usage Add lazy_load_scrollview dependency to your pubspec.yaml: dependen

Quirijn Groot Bluemink 104 Nov 7, 2022
A _Flutter_ package that provides a diagonal scrollview.

Diagonal ScrollView for Flutter THE PACKAGE IS DISCONTINUED! Use InteractiveViewer instead. A Flutter package that allows to scroll in both, horizonta

Ranfi Castillo de Aza 35 Dec 12, 2021
Widget to count the amount of nested widget tree, useful in the dynamic construction of the interface when it is important to know the depth of widget.

widget_tree_depth_counter Widget Tree Depth Counter WidgetTreeDepthCounter is a simple widget to count the amount of nested widget tree, useful in the

Riccardo Cucia 4 Aug 1, 2022
MindInventory 15 Sep 5, 2022
A simple detailed flutter widget that looks almost the same as the real instagram mention widget.

Instagram Mention Widgets 'small details do matter' ❤️ This package provides simple and almost the same UI details that the real Instagram mention wid

AbdulMuaz Aqeel 20 Oct 10, 2022
A customizable carousel slider widget in Flutter which supports inifinte scrolling, auto scrolling, custom child widget, custom animations and built-in indicators.

flutter_carousel_widget A customizable carousel slider widget in Flutter. Features Infinite Scroll Custom Child Widget Auto Play Horizontal and Vertic

NIKHIL RAJPUT 7 Nov 26, 2022
A flutter widget which renders its child outside the original widget hierarchy.

overlay_container A flutter widget which renders its child outside the original widget hierarchy. Demo. This demo is present as an example here. You c

Mustansir Zia 30 Jun 10, 2022
Behruz Hurramov 0 Dec 29, 2021
FT-Custom-Widget - A Custom Widget Built With Flutter

Custom Widget Watch it on YouTube Product Screen Sample when you implement compl

Firgia 5 Mar 29, 2022
A Flutter widget to show an icon collection to pick. This widget extend TextField and has a similar behavior as TextFormField

icon_picker A Flutter widget to show an icon collection to pick. This widget extend TextField and has a similar behavior as TextFormField Usage In the

m3uzz Soluções em TI 11 Sep 27, 2022
Flip widget - A Simple Flip widget For Flutter

flip_widget Flip your widget. Usage FlipWidget( key: _flipKey, child: Co

null 24 Nov 13, 2022
A new Flutter project. Use of Padding Class(Widget) and Card Class (Widget)

Use_Of_Card_And_Padding_Class A new Flutter project. Use of Padding Class(Widget) and Card Class (Widget) Getting Started This project is a starting p

Avinandan Bose 1 Mar 18, 2022
Custom dropdown widget allows to add highly customizable widget in your projects with proper open and close animations and also comes with form required validation.

Custom Dropdown Custom Dropdown package lets you add customizable animated dropdown widget. Features Lots of properties to use and customize dropdown

Abdullah Chauhan 22 Dec 29, 2022