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

universal_stepper 封面
插件详情v1.0.0+1

universal_stepper

为 Flutter 提供一个通用的步骤条小部件。该小部件可用于构建水平和垂直的步骤条。

AndroidiOSWebmacOSWindowsLinux
近 30 天下载
7
喜欢数
5
Pub 分数
160

安装插件

flutter pub add universal_stepper

插件介绍

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

一个功能强大的 Flutter 包,提供通用的步骤条小部件,支持水平和垂直布局。它简化了在所有主要平台上创建表单、引导流程或分阶段流程的逐步界面。该小部件可自定义,并能无缝集成到现有的 Flutter 应用中。设计灵活且易于使用,使开发者能够以最少的代码保持一致的 UI 模式。其跨平台兼容性确保在 Android、iOS、Web、macOS、Windows 和 Linux 上行为一致。

适合场景

  • 引导向导
  • 多步骤表单导航
  • 结账流程设计
  • 进度跟踪接口
  • 设置向导

主要特点

  • 支持横向和纵向方向
  • 跨平台兼容性
  • 可自定义样式
  • 简单的 API 集成
  • 可重用的步骤组件

适合对象

  • 开发人员构建引导式工作流
  • 需要一致步进器 UI 的团队
  • 需要多步骤用户输入的应用程序
  • 使用可重用组件设计系统
  • 跨平台应用程序

使用建议

  • 可能需要额外的样式才能适应复杂主题
  • 有限的内置动画选项
  • 最适合线性步骤序列
  • 不太适合高度动态的步骤逻辑
  • 依赖于正确的状态管理来控制步骤

原始 README

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

A simple package to build steppers with custom elements. You can set up your own body content, badges, and paths using indexed builders.

Vertical Stepper

To create a vertical stepper, set stepperDirection to Axis.vertical.

UniversalStepper(
  inverted: false,
  stepperDirection: Axis.vertical,
  elementBuilder: (context, index) {
    return Expanded(
      child: Container(
        padding: const EdgeInsets.only(left: 10, bottom: 15),
        child: ... // your element
      ),
    );
  },
  badgeBuilder: (context, index) {
    return Container(
      width: 30,
      padding: const EdgeInsets.all(6),
      decoration: const BoxDecoration(
        color: Colors.green,
        borderRadius: BorderRadius.all(Radius.circular(30)),
      ),
      child: const FittedBox(child: Icon(Icons.fastfood, color: Colors.white)),
    );
  },
  pathBuilder: (context, index) {
    return Container(
      color: index == stepperData.length - 1
          ? Colors.transparent
          : (index < currentStep ? Colors.green : Colors.grey),
      width: 4,
    );
  },
  subPathBuilder: (context, index) {
    return Container(
      color: index == stepperData.length - 1
          ? Colors.transparent
          : (index < currentStep ? Colors.green : Colors.grey),
      width: 4,
    );
  },
  elementCount: stepperData.length,
  badgePosition: StepperBadgePosition.start,
)

Here’s an example of what the result might look like:

Parameters

  • elementBuilder: A builder for the content of the stepper.

  • badgeBuilder: A builder for the badge.

  • badgePosition: Determines the alignment of the badge. Options include StepperBadgePosition.start, StepperBadgePosition.center, or StepperBadgePosition.end.

  • pathBuilder: A builder for the main path (e.g., a line, dotted line, etc.). This is the most commonly used path.

  • subPathBuilder: A builder for the secondary path, used when badgePosition is set to StepperBadgePosition.center. This path is displayed under the badge and allows you to control its visibility based on the active step.

  • elementCount: The number of elements in the stepper.

  • inverted: A flag to invert the position of the path and badge relative to the element. By default, this is false, and for vertical steppers, the path appears on the left. When set to true, the path appears on the right. For horizontal steppers, the path appears on the top and when set to true, the path appears on the bottom.

For example, if you set inverted to true and badgePosition to StepperBadgePosition.center, the result will look like this:

Horizontal Stepper

To create a horizontal stepper, set stepperDirection to Axis.horizontal.

Here’s an example of a horizontal stepper:

And here’s the inverted variant:

For full examples, check out the example app.

所属分类

源码仓库

使用此插件的项目

暂无相关数据。