搜尋套件、儲存庫與 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.

所屬分類

原始碼儲存庫

使用此套件的專案

暫無相關資料。