Peek & Pop implementation for Flutter based on the iOS functionality of the same name.

Overview

peek_and_pop

Cosmos Software Cosmos Software

Awesome Flutter

Pub License



Peek & Pop implementation for Flutter based on the iOS functionality of the same name.

Finally, the v1.0.0 release! More fluent, more optimised and more beautiful than ever. Very customisable and very easy to use.

It is highly recommended to read the documentation and run the example project on a real device to fully understand and inspect the full range of capabilities.

Media | Description | Installation | How-to-Use

Notice

  • v0.1.9 and higher no longer requires any modifications to Flutter's normal "binding.dart"! You can leave your Flutter source code alone and happy.

  • If you are updating from an earlier version, you can revert your "binding.dart" to its original format.


Recent

  • The "Quick Actions" feature is now added. It is highly customisable and you can show a dynamic menu with quick action buttons as the view is dragged and snapped very easily. The drag and snap limits will be automatically set according to the menu and the view. snap is now implemented directly to the package. See Media for examples.

  • The "Overlap" and "Alignment" features are now added. These two features create a much more fluent Peek & Pop process that is much more similar to the actual iOS version. See Media for examples.

  • The "Scale Up" and "Scale Down" features are now added. You can use these features to scale a widget down or up as the Peek & Pop process proceeds. "Scale Up" is also supported for the "Indicator" feature out of the box.See Media for examples.

  • Improved enumeration for the stage of the Peek & Pop process.

  • The "Indicator" feature is now added. See Media for examples.

  • Animations are now up to 4x faster with the new optimised blur effect algorithm during the Peek & Pop process.


Warning

  • "isHero" is now removed. It wasn't playing well with the package algorithm and it is considered to be unnecessary for the Peek & Pop process. However, this shouldn't be a problem due to the addition of the new "Overlap" and "Alignment" features. If you must use a Hero widget, only use it while "willBeDone" or "isDone" is true.

  • Old installation instructions are removed. If you wish (for some reason) to use a version older than v0.1.9, see the README of that version for the relevant installation instructions.


Media

Watch on Youtube:

v1.0.0 Showcase Demo | v1.0.0 Technical Preview

v0.1.7

v0.1.0 Mixed

v0.0.1 Normal | v0.0.1 Moveable | v0.0.1 Platform View | v0.0.1 Hero



Description

As a fan of the iOS Peek & Pop functionality, I decided to implement it for Flutter as well.

The package has been tested on iOS but not yet on Android as I don't have access to an Android device with Force Press capabilities. Help about this would be appreciated.

For devices that don't support Force Press, the package comes with an adaptation to Long Press however the Long Press version of this package is still under development and is not yet fully tested so consider it as a developers preview.

(The Long Press version is temporarily removed. It will be added back soon.)

The power move of this package is what I like to call "Gesture Recognition Rerouting". Normally, when a new widget with GestureDetector or similar is pushed over an initial widget used for detecting Force Press or when Navigator is used to pop a new page, the user has to restart the gesture for Flutter to resume updating it. This package fixes that problem as explained in the documentation:

//This function is called by the instantiated [PeekAndPopChild] once it is ready to be included in the Peek & Pop process. Perhaps the most
//essential functionality of this package also takes places in this function: The gesture recognition is rerouted from the [PeekAndPopDetector]
//to the instantiated [PeekAndPopChild]. This is important for avoiding the necessity of having the user stop and restart their Force Press.
//Instead, the [PeekAndPopController] does this automatically so that the existing Force Press can continue to update even when if
//[PeekAndPopDetector] is blocked by the view which is often the case especially when using PlatformViews.

Installation

It is easy. Don't worry.

If you do not wish to use PlatformViews you can skip the installation instructions.

Old installation instructions are removed. If you wish (for some reason) to use a version older than v0.1.9, see the README of that version for the relevant installation instructions.

For properly displaying PlatformViews, this package requires the latest Flutter master branch. Maybe it will work with some other version too but tests made with the webview_flutter seem to only properly display with the latest Flutter master branch which has improved the PlatformViews that allow better functionalities such as proper scaling and proper clipping.

If you do not wish to use PlatformViews, you can skip this step.

To use latest Flutter master branch, run the following command.

Note: Don't forget to add io.flutter.embedded_views_previewYES to your Info.plist. See webview_flutter for more info.

$ git clone -b master https://github.com/flutter/flutter.git
$ flutter channel master
$ flutter upgrade
$ flutter doctor
$ ./flutter/bin/flutter --version

How-to-Use

Also easy.

First of all, as explained in the documentation:

//I noticed that a fullscreen blur effect via the [BackdropFilter] widget is not good to use while running the animations required for the Peek &
//Pop process as it causes a noticeable drop in the framerate- especially for devices with high resolutions. During a mostly static view, the
//drop is acceptable. However, once the animations start running, this drop causes a visual disturbance. To prevent this, a new optimised blur
//effect algorithm is implemented. Now, the [BackdropFilter] widget is only used until the animations are about to start. At that moment, it is
//replaced by a static image. Therefore, to capture this image, your root CupertinoApp/MaterialApp MUST be wrapped in a [RepaintBoundary] widget
//which uses the [background] key. As a result, the Peek & Pop process is now up to 4x more fluent.

TL;DR: Wrap your root CupertinoApp/MaterialApp in a RepaintBoundary widget and use the background GlobalKey from "misc.dart".

This is required for the new optimised blur effect algorithm:

import 'package:peek_and_pop/misc.dart' as PeekAndPopMisc;

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return RepaintBoundary(
      key: PeekAndPopMisc.background,
      child: MaterialApp(
        title: 'Peek & Pop Demo',
        home: MyHomePage(title: 'Peek & Pop Demo')
      )
    );
  }
}

If you wish to use the "ScaleUp" or the "Scale Down" features, wrap the widgets you wish to scale down or scale up during the Peek & Pop process with the scaleUpWrapper and scaleDownWrapper functions from "misc.dart":

@override
Widget build(BuildContext context) {
return Scaffold(
  appBar: AppBar(title: Text(widget.title)),
  body: PeekAndPopMisc.scaleDownWrapper(
        ...,
        0.04,
        ),
    );    
}

Then, create a PeekAndPopController such as:

PeekAndPopController(
  uiChild(),            //Widget uiChild
  false,                //bool uiChildUseCache
 {Key key,
  peekAndPopBuilder,
  peekAndPopBuilderUseCache,
  peekAndPopBuilderAtPeek       : peekAndPopBuilderAtPeek,
  peekAndPopBuilderAtPop        : peekAndPopBuilderAtPop,
  quickActionsBuilder           : quickActionsBuilder,
  sigma                         : 10,
  backdropColor                 : Colors.black,
  alpha                         : 126,
  overlayBuilder                : overlayBuilder,
  useOverlap                    : true,
  customOverlapRect,
  useAlignment,                 : false,
  useIndicator                  : true,
  indicatorScaleUpCoefficient   : 0.01,
  willPeekAndPopComplete        : _willPeekAndPopComplete,
  willPushPeekAndPop            : _willPushPeekAndPop,
  willUpdatePeekAndPop          : _willUpdatePeekAndPop,
  willCancelPeekAndPop          : _willCancelPeekAndPop,
  willFinishPeekAndPop          : _willFinishPeekAndPop,
  willClosePeekAndPop           : _willClosePeekAndPop,
  onPeekAndPopComplete          : _onPeekAndPopComplete,
  onPushPeekAndPop              : _onPushPeekAndPop,
  onUpdatePeekAndPop            : _onUpdatePeekAndPop,
  onCancelPeekAndPop            : _onCancelPeekAndPop,
  onFinishPeekAndPop            : _onFinishPeekAndPop,
  onClosePeekAndPop             : _onFinishPeekAndPop,
  onPressStart                  : _onPressStart,
  onPressUpdate                 : _onPressUpdate,
  onPressEnd                    : _onPressEnd,
  treshold                      : 0.5,
  startPressure                 : 0.125,
  peakPressure                  : 1.0,
  peekScale                     : 0.5,
  peekCoefficient               : 0.05,
  popTransition,
  useHaptics                    : true})
  
Widget uiChild() {}

Widget peekAndPopBuilderAtPeek(BuildContext context, PeekAndPopControllerState _peekAndPopController);
Widget peekAndPopBuilderAtPop(BuildContext context, PeekAndPopControllerState _peekAndPopController);

QuickActionsData quickActionsBuilder(PeekAndPopControllerState _peekAndPopController);

WidgetBuilder overlayBuiler(BuildContext context);

bool _willPeekAndPopComplete(PeekAndPopControllerState _peekAndPopController);
bool _willPushPeekAndPop(PeekAndPopControllerState _peekAndPopController);
bool _willUpdatePeekAndPop(PeekAndPopControllerState _peekAndPopController);
bool _willCancelPeekAndPop(PeekAndPopControllerState _peekAndPopController);
bool _willFinishPeekAndPop(PeekAndPopControllerState _peekAndPopController);
bool _willClosePeekAndPop(PeekAndPopControllerState _peekAndPopController);

void _onPeekAndPopComplete(PeekAndPopControllerState _peekAndPopController);
void _onPushPeekAndPop(PeekAndPopControllerState _peekAndPopController);
void _onUpdatePeekAndPop(PeekAndPopControllerState _peekAndPopController);
void _onCancelPeekAndPop(PeekAndPopControllerState _peekAndPopController);
void _onFinishPeekAndPop(PeekAndPopControllerState _peekAndPopController);
void _onClosePeekAndPop(PeekAndPopControllerState _peekAndPopController);

void _onPressStart(dynamic dragDetails);
void _onPressUpdate(dynamic dragDetails);
void _onPressEnd(dynamic dragDetails);
 

Further Explanations:

For a complete set of descriptions for all parameters and methods, see the documentation.

  • Set [uiChildUseCache] to true if your [uiChild] doesn't change during the Peek & Pop process.
  • Set [peekAndPopBuilderUseCache] to true if your [peekAndPopBuilder] doesn't change during the Peek & Pop process.
  • If [peekAndPopBuilderAtPop] and [peekAndPopBuilderAtPeek] are set, [peekAndPopBuilder] and [peekAndPopBuilderUseCache] are ignored.
  • If one of [peekAndPopBuilderAtPop] and [peekAndPopBuilderAtPeek] is set, the other one must be set too.
  • If [quickActionsBuilder] is set, it is recommended that [peekAndPopBuilderAtPop] and [peekAndPopBuilderAtPop] are set too.
  • [overlayBuilder] is an optional second view to be displayed during the Peek & Pop process. This entire widget is built after everything else.
  • For all [PeekAndPopProcessNotifier] callbacks such as [willPeekAndPopComplete], you can return false to prevent the default action.
  • All [PeekAndPopProcessNotifier] and [PeekAndPopProcessCallback] callbacks will return a reference to the created [PeekAndPopController] state. You can save this instance for further actions.
  • [pageTransition] is the transition to be used when the view is opened directly or when the view is closed. A default [SlideTransition] is provided.
  • Use [PeekAndPopControllerState]'s [void closePeekAndPop()] method to close the Peek & Pop process. Do not call [Navigator.of(context).pop()] directly.
  • Use [PeekAndPopControllerState]'s [stage] variable to get enumeration for the stage of the Peek & Pop process. If you want to only know when the Peek & Pop process will be or is completed, you can also use [willBeDone] or [isDone] variables.

Notes

I started using and learning Flutter only some weeks ago so this package might have some parts that don't make sense, that should be completely different, that could be much better, etc. Please let me know! Nicely!

Any help, suggestion or criticism is appreciated!

Cheers.





You might also like...

A simple detailed flutter widget that looks almost the same as the real instagram mention widget.

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

Oct 10, 2022

An isolated worker for Flutter (Isolate) and Web (Web Worker). Behaves almost the same as the compute function, except it is not a one-off worker.

A singleton isolated worker for all platforms. On most platforms, it uses Flutter's Isolate, except on the web, since Isolate is not available, it use

Nov 11, 2022

RelativeScale is a simple custom sizing system for flutter widgets to achieve the same physical sizes across different devices.

RelativeScale is a simple custom sizing system for flutter widgets to achieve the same physical sizes across different devices.

RelativeScale is a simple custom sizing system for flutter widgets to achieve the same physical sizes across different devices. Usage It is VERY easy

Nov 25, 2022

The same old Weather App, But 'In Flutter , By Me'

The same old Weather App, But 'In Flutter , By Me'

Weather App v1.0.1 About The same old Weather App, But 'In Flutter , By Me' . NB Still in developement Stats ### v1.0.1 - Started a Basic outline of

Sep 7, 2022

[Flutter package] An easy and quick way to check if the local app is updated with the same version in their respective stores (Play Store / Apple Store ).

Retrieve version and url for local app update against store app Android and iOS Features Using as reference packages like in_app_update , version_chec

Nov 9, 2022

Mobile, desktop and website Apps with the same code

Mobile, desktop and website Apps with the same code

Mobile, desktop and website Apps with the same code This project shows how the source code can be architectured to run on multiple devices. As of now,

Jan 1, 2023

Taking many pictures and photos list in the same page

Taking many pictures and photos list in the same page

Custom Camera Preview A component has developed with Flutter Purpose Instead of taking photos of a product and taking them one by one when users need

Oct 28, 2022

Todo app - contains same UI and different state management techniques (without using StatefulWidget)

Todo app - contains same UI and different state management techniques (without using StatefulWidget)

This repo contains same UI and different state management techniques (without using StatefulWidget) to compare and prefer based on your coding style.

May 19, 2022

Display multiple simple messages at a same time.

Display multiple simple messages at a same time.

Simple multipurpse flashes to announce different messages to the user and interact with them. Display multiple flashes at the same time and avoid writ

Oct 10, 2022
Comments
  • Request to Add product in Start Flutter

    Request to Add product in Start Flutter

    Hello,

    I am Maheshwari from team GeekyAnts. On behalf of Start Flutter, we add open source products which we find helpful to the community & also we provide credits to author itself.

    Let me know if you are interested showcase your product in our open source website.

    If yes, then I request you to add MIT Licence in your repo.

    Looking forward to hear from you.

    opened by maheshwari-1153 6
  • Because peek_and_pop >=1.0.2+1 depends on bloc ^2.0.0 which depends on rxdart ^0.22.0, peek_and_pop >=1.0.2+1 requires rxdart ^0.22.0.

    Because peek_and_pop >=1.0.2+1 depends on bloc ^2.0.0 which depends on rxdart ^0.22.0, peek_and_pop >=1.0.2+1 requires rxdart ^0.22.0.

    Because peek_and_pop >=1.0.2+1 depends on bloc ^2.0.0 which depends on rxdart ^0.22.0, peek_and_pop >=1.0.2+1 requires rxdart ^0.22.0.

    Clash, so update the package so that it requires ^0.23.1

    opened by MATTYGILO 4
  • Flutter 1.12 support

    Flutter 1.12 support

    Hello. Flutter 12 is now in release so can you update the plugin to support newest version? I've tried to run pretty_example on iPhone X iOS 13 and it has too much render bugs while usign peek and pop :

    flutter: Another exception was thrown: RenderCustomMultiChildLayoutBox object was given an infinite size during layout.
    flutter: Another exception was thrown: _RenderInkFeatures object was given an infinite size during layout.
    flutter: Another exception was thrown: RenderPhysicalModel object was given an infinite size during layout.
    flutter: Another exception was thrown: RenderPositionedBox object was given an infinite size during layout.
    flutter: Another exception was thrown: RenderAnimatedOpacity object was given an infinite size during layout.
    flutter: Another exception was thrown: RenderExcludeSemantics object was given an infinite size during layout.
    flutter: Another exception was thrown: A RenderFlex overflowed by 51 pixels on the bottom.
    flutter: Another exception was thrown: RenderCustomMultiChildLayoutBox object was given an infinite size during layout.
    flutter: Another exception was thrown: _RenderInkFeatures object was given an infinite size during layout.
    flutter: Another exception was thrown: RenderPhysicalModel object was given an infinite size during layout.
    flutter: Another exception was thrown: RenderPositionedBox object was given an infinite size during layout.
    flutter: Another exception was thrown: RenderAnimatedOpacity object was given an infinite size during layout.
    flutter: Another exception was thrown: RenderExcludeSemantics object was given an infinite size during layout.
    flutter: Another exception was thrown: RenderCustomMultiChildLayoutBox object was given an infinite size during layout.
    flutter: Another exception was thrown: _RenderInkFeatures object was given an infinite size during layout.
    flutter: Another exception was thrown: RenderPhysicalModel object was given an infinite size during layout.
    flutter: Another exception was thrown: RenderPositionedBox object was given an infinite size during layout.
    flutter: Another exception was thrown: RenderAnimatedOpacity object was given an infinite size during layout.
    flutter: Another exception was thrown: RenderExcludeSemantics object was given an infinite size during layout.
    flutter: Another exception was thrown: RenderCustomMultiChildLayoutBox object was given an infinite size during layout.
    flutter: Another exception was thrown: _RenderInkFeatures object was given an infinite size during layout.
    flutter: Another exception was thrown: RenderPhysicalModel object was given an infinite size during layout.
    flutter: Another exception was thrown: RenderPositionedBox object was given an infinite size during layout.
    flutter: Another exception was thrown: RenderAnimatedOpacity object was given an infinite size during layout.
    flutter: Another exception was thrown: RenderExcludeSemantics object was given an infinite size during layout.
    flutter: Another exception was thrown: RenderCustomMultiChildLayoutBox object was given an infinite size during layout.
    flutter: Another exception was thrown: _RenderInkFeatures object was given an infinite size during layout.
    flutter: Another exception was thrown: RenderPhysicalModel object was given an infinite size during layout.
    flutter: Another exception was thrown: RenderPositionedBox object was given an infinite size during layout.
    flutter: Another exception was thrown: RenderAnimatedOpacity object was given an infinite size during layout.
    flutter: Another exception was thrown: RenderExcludeSemantics object was given an infinite size during layout.
    flutter: Another exception was thrown: RenderCustomMultiChildLayoutBox object was given an infinite size during layout.
    flutter: Another exception was thrown: _RenderInkFeatures object was given an infinite size during layout.
    flutter: Another exception was thrown: RenderPhysicalModel object was given an infinite size during layout.
    flutter: Another exception was thrown: RenderPositionedBox object was given an infinite size during layout.
    flutter: Another exception was thrown: RenderAnimatedOpacity object was given an infinite size during layout.
    flutter: Another exception was thrown: RenderExcludeSemantics object was given an infinite size during layout.
    flutter: Another exception was thrown: RenderCustomMultiChildLayoutBox object was given an infinite size during layout.
    flutter: Another exception was thrown: _RenderInkFeatures object was given an infinite size during layout.
    flutter: Another exception was thrown: RenderPhysicalModel object was given an infinite size during layout.
    flutter: Another exception was thrown: RenderPositionedBox object was given an infinite size during layout.
    flutter: Another exception was thrown: RenderAnimatedOpacity object was given an infinite size during layout.
    flutter: Another exception was thrown: RenderExcludeSemantics object was given an infinite size during layout.
    

    If you no longer support flutter's updates, can you change pubspec's flutter dependency to 1.9 from 2.0 ?

    opened by alex-misch 4
  • Library needs to be updated according to the latest Flutter version.

    Library needs to be updated according to the latest Flutter version.

    I am opening this issue in order to centralise all other issues which basically talk about the same problem. I am working on a solution and please follow the workflow from here. Thank you.

    opened by aliyigitbireroglu 1
Owner
AliYigitBireroglu
"It's true that we love one another, I love programming like a little brother."
AliYigitBireroglu
Automatically generate profile picture with random first name and background color. But you can still provide pictures if you have them. As the default color, based on the name of the first letter. :fire: :fire: :fire:

FLUTTER PROFILE PICTURE Automatically generate profile picture with random first name and background color. But you can still provide pictures if you

Aditya Dharmawan Saputra 10 Dec 20, 2022
Startup-Name-Generator-App-in-Flutter - Business Startup Name Generator App in Flutter

Business Startup Name Generator App #About APP: A simple mobile app that generat

AHSAN SIDDZ 0 Jan 30, 2022
Album Image is based in photo_manager package and has the same concept as image_picker but with a more attractive interface to choose an image or video from the device gallery, whether it is Android or iOS

Album Image is based in photo_manager package and has the same concept as image_picker but with a more attractive interface to choose an image or vide

Phuong Vu 2 Oct 13, 2022
A Flutter widget for Scrollview, pop when overscroll

overscroll_pop A Flutter widget for Scrollview, pop when overscroll like Instagram, Pinterest, ... Getting Started Include the package to your project

null 22 Dec 21, 2022
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 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
Build a calculator app in iOS and Android with the same code by using flutter.

flutter_calculator Preview Structure Input Widgets input widgets is all extends StatefulWidget, because they need to response the onTap gesture. Numbe

CYT 82 Nov 24, 2022
Wraps Flutter shared_preferences plugin, providing a iOS Suite Name support, it's helpful for sharing data from App to Widget.

shared_preferences_ios_sn Wraps Flutter shared_preferences plugin and provides an iOS Suite Name support, it's helpful for sharing data from App to iO

null 3 Sep 14, 2022
A Stable GeoFence Library - A flutter project to provide Geo Fence functionality in Android and IOS

A flutter project to provide Geo Fence functionality in Android and IOS Getting Started Android In your AndroidManifest.xml

TARIQUE KHAN 8 Nov 15, 2022