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

slidable_button 封面
插件详情v3.0.0+1

slidable_button

一个简单可自定义的 Flutter 滑动按钮小部件。

AndroidiOSWebmacOSWindowsLinux
近 30 天下载
46
喜欢数
65
Pub 分数
160

安装插件

flutter pub add slidable_button

插件介绍

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

一个简单且可自定义的滑动按钮小部件,适用于 Flutter,允许用户拖动拇指在轨道上滑动以触发操作。它支持自定义样式、动画以及在滑块移动或释放时的回调事件。非常适合用于切换、确认或跨多个平台应用中的交互式控件。该包轻量且易于集成,配置最少。

适合场景

  • 表单确认滑块
  • 切换开关
  • 交互式入门元素
  • 可自定义的操作触发器
  • 用户同意提示

主要特点

  • 完全可自定义的外观
  • 拖拽手势支持
  • 拖动和释放时的回调
  • 流畅的动画
  • 跨平台兼容性
  • 简单的 API 集成

适合对象

  • 寻求轻量级滑块的开发者
  • 需要交互元素的UI设计师
  • 需要用户确认操作的应用程序
  • 跨平台 Flutter 项目
  • 自定义表单组件

使用建议

  • 有限的内置主题
  • 无内置的可访问性功能
  • 需要手动处理边缘情况
  • 不适合复杂的滑块交互
  • 基本用法之外的最小文档

原始 README

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

slidable_button

Pub support

A simple flutter plugin for Slidable Button.

 

Note : This plugin is cloned and remade from swipe_button.

Getting Started

Add dependency
dependencies:
  slidable_button: ^3.0.0+1
Simple to use

Import this library on your code.

import 'package:slidable_button/slidable_button.dart';

Now you can make your slidable button vertically or horizontally by using one of them widget. For horizontal usage example :

    HorizontalSlidableButton(
      width: MediaQuery.of(context).size.width / 3,
      buttonWidth: 60.0,
      color: Theme.of(context).accentColor.withOpacity(0.5),
      buttonColor: Theme.of(context).primaryColor,
      dismissible: false,
      label: Center(child: Text('Slide Me')),
      child: Padding(
        padding: const EdgeInsets.all(8.0),
        child: Row(
          mainAxisAlignment: MainAxisAlignment.spaceBetween,
          children: [
            Text('Left'),
            Text('Right'),
          ],
        ),
      ),
      onChanged: (position) {
        setState(() {
          if (position == SlidableButtonPosition.end) {
            result = 'Button is on the right';
          } else {
            result = 'Button is on the left';
          }
        });
      },
    ),

Vertical usage example :

    VerticalSlidableButton(
      height: MediaQuery.of(context).size.height / 3,
      buttonHeight: 60.0,
      color: Theme.of(context).accentColor.withOpacity(0.5),
      buttonColor: Theme.of(context).primaryColor,
      dismissible: false,
      label: Center(child: Text('Slide Me')),
      child: Padding(
        padding: const EdgeInsets.all(8.0),
        child: Column(
          mainAxisAlignment: MainAxisAlignment.spaceBetween,
          children: [
            Text('Top'),
            Text('Bottom'),
          ],
        ),
      ),
      onChanged: (position) {
        setState(() {
          if (position == SlidableButtonPosition.end) {
            result = 'Button is on the bottom';
          } else {
            result = 'Button is on the top';
          }
        });
      },
    ),
Migration Guide

If you already use this package before v3.x.x you may need to migrate your code to HorizontalSlidableButton or VerticalSlidableButton for specific direction usage because SlidableButton class has been removed start from v3.0.0.

所属分类

源码仓库

使用此插件的项目

暂无相关数据。