Switcher class

自定义滑块开关组件

@param onChanged 当开关状态发生改变时,会回调该函数.

@param open 是否处于打开状态,默认false.

@param enable 是否为可用状态,默认true.

@param width 组件宽度。默认45.

@param onColor 打开状态下的背景色.

@param onChild 打开状态的提示样式.

@param offColor 关闭状态下的背景色.

@param offChild 关闭状态的提示样式.

@param sliderColor 滑块颜色.

@param sliderChild 滑块中的组件。超过范围会被剪裁.

@param boxShadow 组件阴影.

Inheritance

Constructors

Switcher({Key? key, required ValueChanged<bool> onChanged, bool open = false, bool enable = true, double width = 45, Color onColor = const Color(0xFF26B85C), Widget? onChild, Color offColor = const Color(0xFFCCCCCC), Widget? offChild, Color? sliderColor, Widget? sliderChild, List<BoxShadow>? boxShadow})
const

Properties

boxShadow List<BoxShadow>?
final
childOffset double
final
enable bool
final
hashCode int
The hash code for this object.
no setterinherited
height double
final
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
offChild Widget?
final
offColor Color
final
offset double
final
onChanged ValueChanged<bool>
final
onChild Widget?
final
onColor Color
final
open bool
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
sliderChild Widget?
final
sliderColor Color?
final
width double
final

Methods

createElement() StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
inherited
createState() → _SwitcherState
Creates the mutable state for this widget at a given location in the tree.
override
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