BetterButton class

一个高度可配置的按钮组件,支持主题颜色、加载指示器、自定义前缀/后缀、渐变等

Inheritance

Constructors

BetterButton({Key? key, BetterButtonType? type = BetterButtonType.defaultType, VoidCallback? onClick, Color? backgroundColor, Color? borderColor, Color? overlayColor, BorderRadiusGeometry? borderRadius, bool loading = false, double? loadingSize, double? loadingStrokeWidth, Widget? loadingWidget, Color? loadingColor, double? loadingMarginRight, Widget? prefix, Widget? suffix, double? width, double? height, BetterButtonLoadingType loadingType = BetterButtonLoadingType.circular, String? text, TextStyle? textStyle, EdgeInsetsGeometry? padding, bool? plain = false, Gradient? gradient, bool? disableSplash = false, bool? disabled = false, bool? hideContentWhenLoading = true, String? loadingText, Widget? child, double? borderWidth, bool? isShowBorder = true})
创建一个 BetterButton

Properties

backgroundColor Color?
按钮的背景颜色。如果为 null,则从 type 派生颜色
final
borderColor Color?
按钮的边框颜色
final
borderRadius BorderRadiusGeometry?
按钮的圆角半径
final
borderWidth double?
按钮的边框宽度
final
child Widget?
自定义子组件。如果提供,text 将被忽略
final
disabled bool?
按钮是否被禁用
final
disableSplash bool?
是否禁用水波纹效果
final
gradient Gradient?
按钮的背景渐变。优先于 color
final
hashCode int
The hash code for this object.
no setterinherited
height double?
按钮的固定高度
getter/setter pair
hideContentWhenLoading bool?
加载时是否隐藏内容
final
isShowBorder bool?
是否显示边框
final
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
loading bool
是否显示加载状态
final
loadingColor Color?
加载指示器的颜色
final
loadingMarginRight double?
加载指示器右侧的间距
getter/setter pair
loadingSize double?
加载指示器的大小
getter/setter pair
loadingStrokeWidth double?
圆形加载指示器的描边宽度
final
loadingText String?
hideContentWhenLoading 为 false 时,加载期间显示的文本
final
loadingType BetterButtonLoadingType
加载指示器类型
final
loadingWidget Widget?
自定义加载组件。如果提供,将替换内置指示器
final
onClick VoidCallback?
按钮被点击时的回调函数
final
overlayColor Color?
按下时的覆盖/水波纹颜色
final
padding EdgeInsetsGeometry?
按钮的内边距
final
plain bool?
是否渲染朴素(轮廓)样式的按钮
final
prefix Widget?
显示在文本/子组件之前的组件
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
suffix Widget?
显示在文本/子组件之后的组件
final
text String?
当未提供 child 时的文本内容
final
textStyle TextStyle?
text 的文本样式
final
type BetterButtonType?
要使用的预设视觉样式。当为 null 时,回退到主题默认值
final
width double?
按钮的固定宽度
final

Methods

build(BuildContext context) Widget
Describes the part of the user interface represented by this widget.
override
createElement() StatelessElement
Creates a StatelessElement to manage this widget's location in the tree.
inherited
debugDescribeChildren() List<DiagnosticsNode>
Returns a list of DiagnosticsNode objects describing this node's children.
inherited
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep.
inherited
toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) String
A string representation of this object.
inherited
toStringDeep({String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) String
Returns a string representation of this node and its descendants.
inherited
toStringShallow({String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) String
Returns a one-line detailed description of the object.
inherited
toStringShort() String
A short, textual description of this widget.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited