搜索分类、插件与代码仓

bottom_sheet_scaffold 封面
插件详情v0.1.9

bottom_sheet_scaffold

通过滑动 Scaffold 的主体部分来滑动您的底部表单!一个非常简单且可自定义的底部表单实现。

AndroidiOSWebmacOSWindowsLinux
近 30 天下载
214
喜欢数
41
Pub 分数
140

安装插件

flutter pub add bottom_sheet_scaffold

插件介绍

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

BottomSheetScaffold 是一个简单且可自定义的 Flutter 包,允许用户通过滑动 Scaffold 的主体部分来打开底部弹出层。它通过支持直观的手势操作,增强了用户交互体验,使用户能够轻松访问额外内容或控件。该包轻量级、易于集成,并支持所有主要平台,包括 Android、iOS、Web、macOS、Windows 和 Linux。适用于模态框、筛选器或快速操作,提供流畅的动画效果和灵活的自定义选项,无需复杂配置。

适合场景

  • 手势驱动的底部抽屉导航
  • 快速操作面板
  • 筛选或设置叠加
  • 模态内容展示
  • 可自定义的滑动行为

主要特点

  • 从 Scaffold body 滑动打开
  • 跨平台支持
  • 高度可定制的设计
  • 平滑的动画过渡
  • 最少的样板代码
  • 轻松集成到现有支架中

适合对象

  • 寻求简单底部表单手势的开发者
  • 需要直观用户界面交互的应用程序
  • 需要轻量级底部抽屉解决方案的项目
  • 想要自定义底部表单的设计人员
  • 快速原型用户界面流程

使用建议

  • 内置样式选项有限,仅限基本自定义
  • 可能需要额外的逻辑来处理复杂的状态管理
  • 不太适合深度嵌套或多层底部弹出面板
  • 最适合单内容底部弹窗
  • 需要仔细处理可滚动主体中的滚动冲突

原始 README

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

bottom_sheet_scaffold

Slide your bottom sheet by sliding the body of the scaffold!. Very simple and customizable bottom sheet implementation.

Features

  • Easy usage
  • Determine the height of the bottom sheet by sliding the body of the scaffold
  • Draggable bottom sheet body
  • Animated Opacity
  • Fully customizable
  • Listen the status of bottom sheet by using BottomSheetBuilder
  • No need to set any header to slide bottom sheet

Scaffold Swipping

Header Swipping

Gradient Opacity

Fixed height

Custom

Usage

Change your Scaffold into BottomSheetScaffold.

BottomSheetScaffold(
      draggableBody: true,
      dismissOnClick: true,
      barrierColor: Colors.black54,
      bottomSheet: DraggableBottomSheet(
        animationDuration: Duration(milliseconds: 200),
        body: BottomSheetBody(),
        header: BottomSheetHeader(),//header is not required
      ),
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: ScaffoldBody(),
    )
You can customize OnWillPop of BottomSheet
BottomSheetScaffold(
      draggableBody: true,
      dismissOnClick: true,
      onWillPop: (() async {
        if (BottomSheetPanel.isOpen) {
          BottomSheetPanel.close();
          return false;
        } else {
          return true;
        }
      }),
      barrierColor: Colors.black54,
      bottomSheet: DraggableBottomSheet(
        animationDuration: Duration(milliseconds: 200),
        body: BottomSheetBody(),
        header: BottomSheetHeader(),//header is not required
      ),
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: ScaffoldBody(),
    )

Barrier not being displayed in scaffold to be used inside

If you use Scaffold inside BottomSheetScaffold, you should wrap the body of the Scaffold with BarrierViewer. This way you can display the barrier color you defined when the bottom sheet is opened

return BottomSheetScaffold(
      bottomSheet: DraggableBottomSheet(
        animationDuration: const Duration(milliseconds: 200),
        body: Container(
            width: double.infinity,
            height: 500,
            alignment: Alignment.center,
            child: const Text(
              "Bottom Sheet",
              style: TextStyle(fontSize: 36, color: Colors.black),
            )),
        header: Container(
          height: 60,
          color: Colors.blue,
          child: const Center(
              child: Text(
            "Drag me",
            style: TextStyle(color: Colors.white),
          )),
        ),
      ),
      appBar: AppBar(
        title: const Text(
          "My AppBar",
        ),
      ),
      body: Scaffold(
        body: BarrierViewer(
          child: Center(
            child: Column(

DraggableBottomSheet

DraggableBottomSheet(
    {super.key,
    this.maxHeight = 500,
    this.minHeight = 0,
    this.header,
    this.animationDuration = const Duration(milliseconds: 200),
    this.autoSwipped = true,
    this.draggableBody = true,
    this.gradientOpacity = true,
    this.headerVisibilityOnTap = true,
    this.backgroundColor = Colors.white60,
    this.onHide,
    this.radius = 30,
    this.onShow,
    required this.body})

BottomSheetPanel

Open bottom sheet

BottomSheetPanel.open();

Close bottom sheet

BottomSheetPanel.close();

Update height of bottom sheet

BottomSheetPanel.close();

Check if bottom sheet is opened

BottomSheetPanel.isOpen;

Check if bottom sheet is expanded

BottomSheetPanel.isExpanded;

Check if bottom sheet is collapsed

BottomSheetPanel.isCollapsed;

DraggableArea

If you set the parameter "draggableBody" in DraggableBottomSheet to false, you will need the DraggableArea widget to scroll the bottom sheet.

DraggableBottomSheet(
        draggableBody: false,
        body: Column(
          children: [
            DraggableArea(
              child: Container(
                height: 80,
                width: double.infinity,
                color: Colors.blue,
                alignment: Alignment.center,
                child: const Text(
                  "Drag Me",
                  style: TextStyle(color: Colors.white),
                ),
              ),
            ),
            Container(
              height: 500,
              color: Colors.red,
              child: const Center(
                  child: Text(
                "Bottom Sheet",
                style: TextStyle(fontSize: 36, color: Colors.white),
              )),
            )
          ],
        ),
      )

BottomSheetBuilder

Use BottomSheetBuilder if you need to listen bottom sheet status to change something in your page.

BottomSheetBuilder(
        builder: (status, context) {
          return FloatingActionButton(
            onPressed: () {
              if (BottomSheetPanel.isExpanded) {
                BottomSheetPanel.close();
              } else {
                BottomSheetPanel.open();
              }
            },
            child: Icon(!status.isExpanded
                ? Icons.open_in_browser
                : Icons.close_fullscreen),
          );
        },
      )

Example

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key});

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    return BottomSheetScaffold(
      bottomSheet: DraggableBottomSheet(
        body: const Center(
            child: Text(
          "Bottom Sheet",
          style: TextStyle(fontSize: 36, color: Colors.black),
        )),
        header: Container(
          height: 60,
          color: Colors.blue,
          child: const Center(
              child: Text(
            "Drag me",
            style: TextStyle(color: Colors.white),
          )),
        ),
      ),
      appBar: AppBar(
        title: const Text(
          "My AppBar",
        ),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.start,
          children: <Widget>[
            const SizedBox(
              height: 100,
            ),
            BottomSheetBuilder(
              builder: (status, context) {
                return MaterialButton(
                  color: Colors.blue,
                  onPressed: () {
                    if (BottomSheetPanel.isExpanded) {
                      BottomSheetPanel.close();
                    } else {
                      BottomSheetPanel.open();
                    }
                  },
                  child: Icon(!status.isExpanded
                      ? Icons.open_in_browser
                      : Icons.close_fullscreen),
                );
              },
            ),
            const Text(
              'Body of scaffold',
            ),
          ],
        ),
      ),
    );
  }
}

所属分类

依赖

依赖清单 1 项

源码仓库

使用此插件的项目