MiuixSwitchPreference class

带开关的偏好设置行。对应 Kotlin SwitchPreference

MiuixBasicComponent 的末尾追加一个 MiuixSwitch; 点击整行会触发 onChanged 并切换 value。开关本身也可独立交互。

Inheritance

Constructors

MiuixSwitchPreference({Key? key, required bool value, required ValueChanged<bool> onChanged, required String title, MiuixBasicComponentColors? titleColor, String? summary, MiuixBasicComponentColors? summaryColor, Widget? startAction, List<Widget>? endActions, Widget? bottomAction, MiuixSwitchColors? switchColors, EdgeInsetsGeometry insideMargin = MiuixBasicComponentDefaults.insideMargin, bool holdDownState = false, bool enabled = true})
const

Properties

bottomAction Widget?
底部内容(可选),位于主行下方。
final
enabled bool
是否启用。
final
endActions List<Widget>?
开关之前的额外内容(可选);以 Row 排列,末端 8dp 间距, 并以 Flexible(loose) 容纳,避免与开关争抢空间。
final
hashCode int
The hash code for this object.
no setterinherited
holdDownState bool
是否处于按压态(用于外部强制按下视觉效果)。
final
insideMargin EdgeInsetsGeometry
内边距,默认 MiuixBasicComponentDefaults.insideMargin
final
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
onChanged ValueChanged<bool>
开关状态变更回调(非空)。
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
startAction Widget?
起始侧内容(可选)。
final
summary String?
行摘要(可选)。
final
summaryColor MiuixBasicComponentColors?
摘要颜色;为 null 时取 MiuixBasicComponentDefaults.summaryColor
final
switchColors MiuixSwitchColors?
开关颜色;为 null 时取 MiuixSwitchDefaults.switchColors
final
title String
行标题。
final
titleColor MiuixBasicComponentColors?
标题颜色;为 null 时取 MiuixBasicComponentDefaults.titleColor
final
value bool
当前开关状态。
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