DHSlider class

@author Evan @since 2020-03-09 @describe: 滑动条控件

设置thumb和track有两种形态 第一种使用xxColor属性设置,具体使用见示例。 第二种使用trackImage和thumbImage属性设置。 xxColor和xxImage设置方式互斥。 使用xxImage属性设置,相对应的xxColor应该设置transparent, 具体情况可根据需求来定。

使用xxColor方式,直接配置DHSlider部分即可,使用xxImage方式较xxColor特殊些,示例如下: 1.获取ui.Image Future<List<ui.Image>> getImageFuture(){ return Future.wait( ImageLoader.loadImageByProvider(AssetImage("images/slider_bck.png")), ImageLoader.loadImageByProvider(AssetImage("images/thumb.png"))) ); } 2.使用FutureBuilder创建DHSlider。 使用实例如下: Widget dhSlider = FutureBuilder( future: sliderFuture, builder: (BuildContext context, AsyncSnapshot<List<ui.Image>> snapshot){ List<ui.Image> images = snapshot.data; return DHSlider( value: value, trackHeight: 13, width: double.infinity, height: 40, activeTrackColor: Colors.red, inactiveTrackColor: Colors.yellow, thumbColor: Colors.transparent, disabledThumbColor: Colors.transparent, disabled: disabled, enabledThumbRadius: 17, margin: EdgeInsets.symmetric(horizontal: 10), thumbBorderSide: BorderSide(color: Colors.red, ), trackImage: images?.first, thumbImage: images?.last, onChanged: (value) { this.setState(() { this.value = value; }); }, min: 1, max: 100, );

Inheritance

Constructors

DHSlider({Key? key, SliderTrackShape? trackShape, Image? trackImage, double? trackHeight, Color? activeTrackColor, Color? inactiveTrackColor, Color? disabledActiveTrackColor, Color? disabledInactiveTrackColor, Color? thumbColor, Color? disabledThumbColor, double enabledThumbRadius = 12.0, double? disabledThumbRadius, Image? thumbImage, SliderComponentShape? thumbShape, SliderComponentShape? indicatorShape, Indicator? indicator, IndicatorStyle? indicatorStyle, BorderSide? thumbBorderSide, required double value, bool disabled = false, double min = 0.0, double max = 1.0, int? divisions, String? label, FocusNode? focusNode, bool autoFocus = false, ShowValueIndicator? showValueIndicator, TextStyle? indicatorTextStyle, ValueChanged<double>? onChangeStart, ValueChanged<double>? onChangeEnd, ValueChanged<double>? onChanged, double? width, double? height, Color? backgroundColor, EdgeInsetsGeometry? padding, EdgeInsetsGeometry? margin})
DHSlider.image({Key? key, double? trackHeight, required Image? trackImage, double enabledThumbRadius = 12.0, double? disabledThumbRadius, required Image? thumbImage, required double value, double min = 0.0, double max = 1.0, int? divisions, String? label, FocusNode? focusNode, bool autoFocus = false, SliderComponentShape? indicatorShape, Indicator? indicator, IndicatorStyle? indicatorStyle, ShowValueIndicator? showValueIndicator, TextStyle? indicatorTextStyle, ValueChanged<double>? onChangeStart, ValueChanged<double>? onChangeEnd, ValueChanged<double>? onChanged, bool disabled = false, double? width, double? height, Color? backgroundColor, EdgeInsetsGeometry? padding, EdgeInsetsGeometry? margin, bool inScroll = false})
使用track 和 thumb 图片

Properties

activeTrackColor Color?
可用状态左侧轨道颜色
final
autoFocus bool
是否自动获取焦点
final
backgroundColor Color?
控件背景颜色
final
disabled bool
disabled true 时,控件不可用
final
disabledActiveTrackColor Color?
不可用状态左侧轨道颜色
final
disabledInactiveTrackColor Color?
不可用状态右侧轨道颜色
final
disabledThumbColor Color?
不可用状态thumb 颜色
final
divisions int?
滑条刻度分为具体份数
final
focusNode FocusNode?
焦点节点
final
hashCode int
The hash code for this object.
no setterinherited
height double?
控件高度
final
inactiveTrackColor Color?
可用状态右侧轨道颜色
final
indicatorShape SliderComponentShape?
滑条指示器形状,默认DHIndicatorShape
final
indicatorTextStyle TextStyle?
指示器文本样式
final
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
label String?
slider气泡标签
final
margin EdgeInsetsGeometry?
控件边距
final
max double
滑条最小值
final
min double
滑条最大值
final
onChanged ValueChanged<double>?
滑动值改变回调
final
onChangeEnd ValueChanged<double>?
滑动结束回调
final
onChangeStart ValueChanged<double>?
滑动开始回调
final
padding EdgeInsetsGeometry?
控件填充
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
showValueIndicator ShowValueIndicator?
设置显示器样式
final
thumbColor Color?
可用状态thumb颜色
final
thumbShape SliderComponentShape
滑条thumb形状, 默认DHThumbShape
final
trackHeight double?
轨道高度
final
trackShape SliderTrackShape
滑条轨道形状,默认圆角矩形DHSliderTrackShape
final
value double
当前滑条值
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}) 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