搜索插件、代码仓与 APP 分类

插件详情v1.0.1

stopper

一个底部弹出菜单,可以通过拖动展开到预定义的某个停止高度。

近 30 天下载
18
喜欢数
21
Pub 分数
40

安装插件

flutter pub add stopper

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

Stopper 是一个 Flutter 包,提供具有预设停止高度的底部弹出面板,允许用户拖动并展开到特定位置。它通过在设定限制内实现平滑、受控的扩展来增强用户交互体验,非常适合模态窗口或补充内容面板。该包轻量且可无缝集成到现有的 Flutter 应用中。它支持自定义停止点和动画,适用于直观的 UI 设计。源代码公开托管在 GitHub 上,以确保透明度并支持贡献。

适合场景

  • 具有固定扩展级别的交互式底部弹出层
  • 可自定义的模态面板
  • 增强用户对面板高度的控制
  • 动态内容叠加
  • 流畅的拖拽展开界面

主要特点

  • 预定义停止高度
  • 基于拖拽的展开
  • 可自定义的停止点
  • 平滑动画
  • 轻量级且易于集成

适合对象

  • 开发交互式底部抽屉的开发者
  • 需要受控面板扩展的应用程序
  • 需要精确底部表单行为的 UI
  • 专注于用户体验的Flutter项目
  • 设计具有统一面板交互的系统

使用建议

  • 未提及任何平台特定限制
  • 需要手动配置停止高度
  • 仅限底部弹出面板使用场景
  • 无内置状态管理
  • 依赖外部依赖项以实现高级功能

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

Stopper

A bottom sheet that can be expanded to one of the pre-defined stop heights by dragging.

animated image

Introduction

Some iOS applications have a bottom sheet that has two states: half-expanded and fully expanded. The standard showBottomSheet method lacks such a capability. The complexity in implementing this behavior arises when the the bottom sheet needs to be scrollable, making scroll and drag event handling difficult as these gestures can be used for scrolling the list as well as for dragging the bottom sheet up/down, depending on the position of the bottom sheet and the current scroll position. The Stopper plugin addresses this problem by:

  • Letting the developer define discreet height values (stops) to which the bottom sheet can be expanded;
  • Using the builder pattern to build the bottom sheet depending on the current stop value;
  • Instantiating ScrollController and ScrollPhysics objects and passing them to the bottom sheet builder;
  • Using animations to make transitions of the bottom sheet between the stops look natural;
  • Providing a convenient showStopper function to be used instead of showBottomSheet in order to handle dismissal of the bottom sheet by the user.

This plugin utilizes bottom sheet functionality from the Scaffold widget and avoids copy/paste from the standard library, making the implementation clear and easy to maintain.

Example

import 'package:stopper/stopper.dart';
//...
final height = MediaQuery.of(context).size.height;
//...
MaterialButton(
  child: Text("Show Stopper"),
  onPressed: () {
    showStopper(
      context: context,
      stops: [0.5 * height, height],
      builder: (context, scrollController, scrollPhysics, stop) {
        return ListView(
          controller: scrollController,
          physics: scrollPhysics,
          children: [
            //...
          ]
        );
      }
    );
  },
  ...
)

Note: The build context passed to showStopper must have a Scaffold widget as an ancestor. Therefore it's recommended to use Builder to build the body of the Scaffold. See the complete example app provided in this package for details on this approach.

所属分类

源码仓库

使用此插件的项目

暂无相关数据。