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 | 类型 | 描述 |
---|---|---|
type | primary | success | warning | danger | null | 按钮类型 |
size | large | small | mini | null | 按钮大小 |
text | String | 文本 |
block | bool | 尺寸 |
plain | bool | 是否为朴素按钮 |
square | bool | 方形按钮 |
round | bool | 圆形按钮 |
disabled | bool | 禁用 |
loading | bool | 加载状态 |
loadingText | String | 加载文本 |
loadingSize | double | 加载图标大小 |
icon | Icon | IconData | Widget | 按钮图标 |
onTap | Function() | 点击回调 |
borderColor | Color | 边框颜色 |
bgColor | Color | 背景颜色 |