Skip to content
On this page

Button 按钮

代码演示

按钮类型

dart
const Button(text: "Primary", type: ButtonType.primary),
const Button(text: "Success", type: ButtonType.success),
const Button(text: "Default", type: null),
const Button(text: "Danger", type: ButtonType.danger),
const Button(text: "Warning", type: ButtonType.warning),

朴素按钮

dart
const Button(text: "Plain", type: ButtonType.primary, plain: true),
const Button(text: "Plain", type: ButtonType.success, plain: true),

禁用状态

dart
const Button(
  text: "Disabled",
  type: ButtonType.primary,
  disabled: true,
),
const Button(
  text: "Disabled",
  type: ButtonType.success,
  disabled: true,
),

按钮形状

dart
const Button(text: "Square", type: ButtonType.primary, square: true),
const Button(text: "Round", type: ButtonType.success, round: true),

按钮大小

dart
const Button(
  text: "Large",
  type: ButtonType.primary,
  size: ButtonSize.large,
  block: true,
),
const Button(
  text: "Default",
  type: ButtonType.primary,
  size: null,
),
const Button(
  text: "Small",
  type: ButtonType.primary,
  size: ButtonSize.small,
),
const Button(
  text: "Mini",
  type: ButtonType.primary,
  size: ButtonSize.mini,
),

API

Props类型描述
typeprimary | success | warning | danger | null按钮类型
sizelarge | small | mini | null按钮大小
textString文本
blockbool尺寸
plainbool是否为朴素按钮
squarebool方形按钮
roundbool圆形按钮
disabledbool禁用
loadingbool加载状态
loadingTextString加载文本
loadingSizedouble加载图标大小
iconIcon | IconData | Widget按钮图标
onTapFunction()点击回调
borderColorColor边框颜色
bgColorColor背景颜色