SuperWidget 是一个功能丰富的 Flutter UI 组件库,提供了一系列常用的、高度可定制的 UI 组件,帮助开发者快速构建美观的应用界面。
-
基础组件
-
SuperText: 增强型文本组件,支持自定义样式和交互参数名 类型 描述 默认值 textString 显示的文本内容 - styleTextStyle? 文本样式 null textAlignTextAlign? 文本对齐方式 null maxLinesint? 最大行数 null overflowTextOverflow? 文本溢出处理方式 null onTapVoidCallback? 点击回调 null TextAlign 枚举值:
枚举值 描述 left左对齐 right右对齐 center居中对齐 justify两端对齐 start起始位置对齐 end结束位置对齐 TextOverflow 枚举值:
枚举值 描述 clip裁剪溢出文本 fade淡出溢出文本 ellipsis使用省略号表示溢出 visible显示溢出文本 -
SuperRichText: 富文本组件,支持混合文本样式参数名 类型 描述 默认值 textSpansList 文本片段列表 - textAlignTextAlign? 文本对齐方式 null maxLinesint? 最大行数 null overflowTextOverflow? 文本溢出处理方式 null -
SuperButton: 自定义按钮组件,支持多种样式和状态参数名 类型 描述 默认值 textString 按钮文本 - onPressedVoidCallback? 点击回调 null iconWidget? 按钮图标 null colorColor? 按钮背景色 null disabledColorColor? 禁用状态背景色 null paddingEdgeInsetsGeometry? 内边距 null borderRadiusBorderRadiusGeometry? 圆角 null isLoadingbool 是否显示加载状态 false buttonTypeButtonType 按钮类型 ButtonType.primary ButtonType 枚举值:
枚举值 描述 primary主要按钮 secondary次要按钮 outline轮廓按钮 text文本按钮 link链接按钮 -
SuperTextField: 增强型输入框组件参数名 类型 描述 默认值 hintString? 提示文本 null controllerTextEditingController? 控制器 null onChangedValueChanged? 文本变化回调 null onSubmittedValueChanged? 提交回调 null obscureTextbool 是否隐藏文本 false keyboardTypeTextInputType 键盘类型 TextInputType.text maxLinesint 最大行数 1 prefixIconWidget? 前缀图标 null suffixIconWidget? 后缀图标 null textInputActionTextInputAction 输入动作 TextInputAction.done TextInputType 枚举值:
枚举值 描述 text普通文本 multiline多行文本 number数字 phone电话号码 datetime日期时间 emailAddress邮箱地址 urlURL visiblePassword可见密码 name姓名 streetAddress街道地址 TextInputAction 枚举值:
枚举值 描述 none无动作 unspecified未指定 done完成 go前往 search搜索 send发送 next下一个 previous上一个 continueAction继续 join加入 route路由 emergencyCall紧急呼叫 newline新行 -
SuperDivider: 自定义分割线组件参数名 类型 描述 默认值 heightdouble 高度 1.0 colorColor 颜色 Colors.grey indentdouble 左侧缩进 0.0 endIndentdouble 右侧缩进 0.0 thicknessdouble 厚度 1.0 typeDividerType 分割线类型 DividerType.horizontal DividerType 枚举值:
枚举值 描述 horizontal水平分割线 vertical垂直分割线 -
SuperBody: 页面主体容器组件参数名 类型 描述 默认值 childWidget 子组件 - paddingEdgeInsetsGeometry? 内边距 null backgroundColorColor? 背景色 null scrollDirectionAxis 滚动方向 Axis.vertical Axis 枚举值:
枚举值 描述 horizontal水平方向 vertical垂直方向 -
SuperKeepWrapper: 状态保持包装组件参数名 类型 描述 默认值 childWidget 需要保持状态的子组件 - keepAlivebool 是否保持状态 true
-
-
加载组件
-
SuperLoad: 加载状态管理组件参数名 类型 描述 默认值 controllerSuperLoadController 控制器 - onTapFutureOr Function(Map<String, String>?)? 点击回调 null childWidget 内容组件 - paramsMap<String, String>? 自定义参数 null loadTypeLoadType 加载类型 LoadType.page LoadType 枚举值:
枚举值 描述 page页面加载 dialog对话框加载 toast提示加载 -
SuperLoadPage: 页面加载组件参数名 类型 描述 默认值 statusSuperLoadStatus 加载状态 - childWidget 内容组件 - onTapVoidCallback? 点击回调 null animationTypeAnimationType 动画类型 AnimationType.fade AnimationType 枚举值:
枚举值 描述 fade淡入淡出 scale缩放 slide滑动 none无动画 -
SuperLoadStatus: 加载状态枚举枚举值 描述 loading加载中 empty空数据 error错误 netError网络错误 content正常内容 other其他状态
-
-
Sliver 组件
-
SliverPinnedPersistentHeader: 固定头部组件参数名 类型 描述 默认值 childWidget 头部内容 - pinnedbool 是否固定 true floatingbool 是否浮动 false stretchModeStretchMode 拉伸模式 StretchMode.zoomBackground StretchMode 枚举值:
枚举值 描述 zoomBackground背景缩放 blurBackground背景模糊 fadeTitle标题淡出 -
SliverPinnedToBoxAdapter: 固定盒子适配器参数名 类型 描述 默认值 childWidget 子组件 - pinnedbool 是否固定 true stretchTriggerOffsetdouble 拉伸触发偏移 100.0 -
SliverAppbarExtended: 扩展应用栏组件参数名 类型 描述 默认值 titleWidget 标题 - actionsList? 操作按钮 null pinnedbool 是否固定 true floatingbool 是否浮动 false expandedHeightdouble 展开高度 200.0 collapsedHeightdouble 折叠高度 56.0 toolbarHeightdouble 工具栏高度 56.0 leadingWidthdouble 前导宽度 56.0 backgroundColorColor? 背景色 null elevationdouble 阴影高度 4.0 shapeShapeBorder? 形状 null iconThemeIconThemeData? 图标主题 null actionsIconThemeIconThemeData? 操作图标主题 null textThemeTextTheme? 文本主题 null primarybool 是否为主要应用栏 true centerTitlebool 标题是否居中 false excludeHeaderSemanticsbool 是否排除头部语义 false titleSpacingdouble 标题间距 16.0 collapsedOpacitydouble 折叠不透明度 0.0 stretchModesList 拉伸模式列表 [StretchMode.zoomBackground] -
SliverToNestedScrollBoxAdapter: 嵌套滚动适配器参数名 类型 描述 默认值 childWidget 子组件 - controllerScrollController? 滚动控制器 null physicsScrollPhysics? 滚动物理特性 null cacheExtentdouble? 缓存范围 null
-
-
弹出组件
-
SuperPopup: 自定义弹出框组件参数名 类型 描述 默认值 titleString? 标题 null contentWidget 内容 - actionsList? 操作按钮 null barrierDismissiblebool 点击背景是否关闭 true backgroundColorColor? 背景色 null shapeShapeBorder? 形状 null animationTypeAnimationType 动画类型 AnimationType.fade positionPopupPosition 弹出位置 PopupPosition.center PopupPosition 枚举值:
枚举值 描述 center居中 top顶部 bottom底部 left左侧 right右侧 topLeft左上角 topRight右上角 bottomLeft左下角 bottomRight右下角
-
- 添加依赖
dependencies:
super_widget: ^latest_version- 导入包
import 'package:super_widget/super_widget.dart';- 配置(可选)
// 在应用初始化时配置
SuperWidgetConfig.instance.configure(
// 自定义配置项
);- 使用 SuperButton
SuperButton(
text: '确定',
onPressed: () {
// 处理点击事件
},
)- 使用 SuperTextField
SuperTextField(
hint: '请输入内容',
onChanged: (value) {
// 处理输入变化
},
)- 使用 SuperLoadPage
SuperLoadPage(
status: SuperLoadStatus.loading,
child: YourPageContent(),
)更多详细用法请参考各组件的具体文档说明。
- 使用 SuperKeepWrapper 时需要注意内存管理
- SuperPopup 建议在路由级别使用
- Sliver 相关组件需要在 CustomScrollView 中使用
欢迎提交 Issue 和 Pull Request 来帮助改进这个项目。