{"id":13684370,"url":"https://github.com/a62527776a/flutter-longpresspreview","last_synced_at":"2026-02-02T19:18:24.925Z","repository":{"id":92795143,"uuid":"297088106","full_name":"a62527776a/flutter-longpresspreview","owner":"a62527776a","description":" Long press to show the sliding pop-up window. Imitate the App Store interaction method.","archived":false,"fork":false,"pushed_at":"2020-10-26T13:13:36.000Z","size":17807,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-08-03T14:07:30.692Z","etag":null,"topics":["dragable","flutter"],"latest_commit_sha":null,"homepage":"https://a62527776a.github.io/flutter-longpress-preview-demo/index.html","language":"Dart","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/a62527776a.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2020-09-20T13:59:45.000Z","updated_at":"2023-11-30T06:07:43.000Z","dependencies_parsed_at":null,"dependency_job_id":"4de98ec6-de60-4875-82f4-b2c6972b6bb8","html_url":"https://github.com/a62527776a/flutter-longpresspreview","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/a62527776a%2Fflutter-longpresspreview","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/a62527776a%2Fflutter-longpresspreview/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/a62527776a%2Fflutter-longpresspreview/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/a62527776a%2Fflutter-longpresspreview/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/a62527776a","download_url":"https://codeload.github.com/a62527776a/flutter-longpresspreview/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224224786,"owners_count":17276428,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dragable","flutter"],"created_at":"2024-08-02T14:00:32.818Z","updated_at":"2026-02-02T19:18:24.870Z","avatar_url":"https://github.com/a62527776a.png","language":"Dart","funding_links":[],"categories":["Dart"],"sub_categories":[],"readme":"# long_press_preview\n\n[![pub package](https://img.shields.io/pub/v/long_press_preview.svg)](https://pub.dartlang.org/packages/long_press_preview)\n\n![ezgif-6-a56436a2339f.gif](https://i.loli.net/2020/10/18/u4WmMPb6Av2ZQNc.gif)\n\n用于任意组件长按并展示可拖动弹窗  \nLong press and show draggable dialog of any widget.\n\n可拖动弹窗以及多手势回调  \nDraggable dialog and multi gesture callback provides.\n\n上拉或者松开关闭弹窗  \nDrag up or Drag down close dialog.\n\n## web demo preview\n\nhttps://a62527776a.github.io/flutter-longpress-preview-demo/index.html\n\n## example apk\n\nhttps://a62527776a.github.io/flutter-longpress-preview-demo/app-release.apk\n\n## install\nadd next line to pubspec.yaml\n``` yaml\nlong_press_preview: ^0.0.7\n```\n\n``` cmd\n$ flutter pub get\n```\n\n## How to use\n\n``` Dart\nimport 'package:long_press_preview/long_press_preview.dart';\n```\n包裹你的子组件并且构建你的弹窗样式  \n--------------------------------------------------\nWrap your child widget and build your dialog widget\n``` Dart\nLongPressPreview(\n    child: Container(height: 30, width: 30, color: red),\n    content: Container(height: 300, width: 300, child: Text('这是一个String')),\n    // dialogSize: Size(300, 300), // Optional\n    onFingerCallBack: onFingerCallBack,\n    // 单击组件时回调，请不要自己嵌套GestureDetector组件\n    // Call back when the widget is clicked, please do not nest GestureDetector widget yourself\n    onTap: () =\u003e () =\u003e Navigator.push(context, MaterialPageRoute(builder: (context) =\u003e SecondScreen()));\n)\n```\n\nonFingerCallBack 将会回调手势事件以及卸载实例的函数  \n--------------------------------------------------\nonFingerCallBack Will callback gesture events and uninstall the instance\n``` Dart\n// This is when the fingers are released uninstall dialog and navigator to next page example\n// 这是手指松开时卸载弹窗并且跳转到下一个页面的🌰\nvoid onFingerCallBack(LongPressPreviewFingerEvent event, Function dispose) {\n    switch (event) {\n        // 弹窗创建时回调 （dispose函数是空的）\n        // dialog create event callback (dispose function is empty)\n        case LongPressPreviewFingerEvent.long_press_start:\n        break;\n        // 手指将弹窗滑动到上方时回调\n        // Call back when you slide the dialog with your finger\n        case LongPressPreviewFingerEvent.long_press_drag_top:\n        break;\n        // 手指松开的时候回调\n        // finger leave screen callback\n        case LongPressPreviewFingerEvent.long_press_end:\n        dispose();\n        Navigator.push(context, MaterialPageRoute(builder: (context) =\u003e SecondScreen()));\n        break;\n        // 手指滑动到底部时的回调（dispose函数是空的）\n        // finger sliding to the bottom callback(dispose is empty)\n        case LongPressPreviewFingerEvent.long_press_cancel:\n        break;\n        default:\n    }\n}\n\n```\n\n\n## Quick reference\nProperty | What does it do(cn) | What does it do(en)\n----------------   |---------------- | ---------------\nchild              | 长按这个组件将弹窗口 | Long press on this widget will pop up dialog\ncontent            | 弹窗展示的内容 | display to user by content \nonFingerCallBack   | 手势的回调 | gesture callback\ndialogSize         | 弹窗的大小(可选 default 300x300) | dialog size (optional default 300x300)\nonTap              | 单击组件时回调，请不要自己嵌套GestureDetector组件 | Call back when the widget is clicked, please do not nest GestureDetector widget yourself\n\n## onFingerCallBack params\n``` dart\nonFingerCallBack(LongPressPreviewFingerEvent event, Function dispose)\n```\nonFingerCallBack拥有两个参数 第一个参数类型是LongPressPreviewFingerEvent 这是一个枚举值 拥有long_press_start, long_press_end, \nlong_press_cancel, long_press_drag_top四个值。  \n--------------------------------------------------\nonFingerCallBack has tow param. One is  LongPressPreviewFingerEvent. This is an enumeration with four types. long_press_start, long_press_end, long_press_cancel, long_press_drag_top\n\nenum LongPressPreviewFingerEvent\nProperty | What does it do(cn) | What does it do(en)\n----------------   |---------------- | ---------------\nlong_press_start | 创建弹窗时回调 | Callback when create dialog\nlong_press_end | 松开手指时回调 | Callback when release your finger\nlong_press_cancel | 滑到下方时回调 | Callback when slider to bottom \nlong_press_drag_top | 滑到上方时回调 | Callback when slider to top\n\n第二个参数是一个函数，当第一个参数的类型为LongPressPreviewFingerEven.long_press_drag_top or LongPressPreviewFingerEven.long_press_end，调用第二个参数将卸载弹窗的实例。否则将什么也不会发生。这用于您希望在拖动到上方或者长按结束时卸载弹窗并且做其他事情（比如说跳转到下一个页面)  \n--------------------------------------------------\nthe second param is a function. when first params is LongPressPreviewFingerEven.long_press_drag_top or LongPressPreviewFingerEven.long_press_end, call the second param will uninstall dialog instance. Otherwise nothing will happen.This is used if you want to unload the pop-up window and do something else (such as jump to the next page) when you drag above or at the end of a long press\n\n\nTODO:\n* 优化弹窗动画\n\n* ~~onTap的触发在touch动画执行一遍后 而不是现在的50ms后~~\n* ~~优化一下touch动画~~\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fa62527776a%2Fflutter-longpresspreview","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fa62527776a%2Fflutter-longpresspreview","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fa62527776a%2Fflutter-longpresspreview/lists"}