在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):Ali-Azmoud/flutter_xlider开源软件地址(OpenSource Url):https://github.com/Ali-Azmoud/flutter_xlider开源编程语言(OpenSource Language):Dart 98.0%开源软件介绍(OpenSource Introduction):flutter_xlider
(Flutter Slider) A material design slider and range slider, horizontal and vertical, with rtl support and lots of options and customizations for flutter !! Since version 3.4.0-dev.3, step type is no longer Get StartedSingle SliderA single slider FlutterSlider(
values: [300],
max: 500,
min: 0,
onDragging: (handlerIndex, lowerValue, upperValue) {
_lowerValue = lowerValue;
_upperValue = upperValue;
setState(() {});
},
) To make slider FlutterSlider(
...
rtl: true,
...
) Range SliderA simple example of range slider FlutterSlider(
values: [30, 420],
rangeSlider: true,
max: 500,
min: 0,
onDragging: (handlerIndex, lowerValue, upperValue) {
_lowerValue = lowerValue;
_upperValue = upperValue;
setState(() {});
},
) Vertical AxisYou can change the axis of your slider by setting FlutterSlider(
...
axis: Axis.vertical,
...
) HandlersYou can customize handlers using
FlutterSlider(
...
handler: FlutterSliderHandler(
decoration: BoxDecoration(),
child: Material(
type: MaterialType.canvas,
color: Colors.orange,
elevation: 3,
child: Container(
padding: EdgeInsets.all(5),
child: Icon(Icons.adjust, size: 25,)),
),
),
rightHandler: FlutterSliderHandler(
child: Icon(Icons.chevron_left, color: Colors.red, size: 24,),
),
...
) Handler Scale AnimationYou can control the scale animation type of your handlers, it's duration and it's scale size using FlutterSlider(
...
handlerAnimation: FlutterSliderHandlerAnimation(
curve: Curves.elasticOut,
reverseCurve: Curves.bounceIn,
duration: Duration(milliseconds: 500),
scale: 1.5
),
...
) if you don't want scale animation, then just pass TrackbarsTo customize track bars you can use FlutterSlider(
...
trackBar: FlutterSliderTrackBar(
activeTrackBarHeight: 5,
),
...
)
FlutterSlider(
...
trackBar: FlutterSliderTrackBar(
inactiveTrackBar: BoxDecoration(
borderRadius: BorderRadius.circular(20),
color: Colors.black12,
border: Border.all(width: 3, color: Colors.blue),
),
activeTrackBar: BoxDecoration(
borderRadius: BorderRadius.circular(4),
color: Colors.blue.withOpacity(0.5)
),
),
...
) Central WidgetIf you want to have a widget in the middle of your slider, you can use FlutterSlider(
...
trackBar: FlutterSliderTrackBar(
centralWidget: Container(
decoration: BoxDecoration(
color: trackBarColor,
borderRadius: BorderRadius.circular(50)
),
width: 9,
height: 9,
),
),
...
) TooltipsIn order to customize your tooltips, you can use FlutterSlider(
...
tooltip: FlutterSliderTooltip(
textStyle: TextStyle(fontSize: 17, color: Colors.white),
boxStyle: FlutterSliderTooltipBox(
decoration: BoxDecoration(
color: Colors.redAccent.withOpacity(0.7)
)
)
),
...
) Here there is a range slider with customized handlers, trackbars and tooltips Tooltip PrefixYou can use FlutterSlider(
...
tooltip: FlutterSliderTooltip(
leftPrefix: Icon(Icons.attach_money, size: 19, color: Colors.black45,),
rightSuffix: Icon(Icons.attach_money, size: 19, color: Colors.black45,),
),
...
) Tooltip FormatIf you want to change the format of the value of tooltip you can use FlutterSlider(
...
tooltip: FlutterSliderTooltip(
format: (String value) {
return value + ' ! ';
}
),
...
) Tooltip CallbackIf you want to fully change tooltip widget and use your own customized widget, you can use FlutterSlider(
...
tooltip: FlutterSliderTooltip(
custom: (value) {
return Text(value.toString());
}
),
...
) Disable TooltipTo disable tooltips, use FlutterSlider(
...
tooltip: FlutterSliderTooltip(
disabled: true,
),
...
) Tooltip DirectionTo change the direction of the tooltip, you can use FlutterSlider(
...
tooltip: FlutterSliderTooltip(
direction: FlutterSliderTooltipDirection.right,
),
...
) Tooltip Position OffsetBy default tooltip alignment is center, but you can modify it's FlutterSlider(
...
tooltip: FlutterSliderTooltip(
positionOffset: FlutterSliderTooltipPositionOffset(
top: -100
),
),
...
) Always Show TooltipsTooltips always displayed if this property is set to FlutterSlider(
...
tooltip: FlutterSliderTooltip(
alwaysShowTooltip: true,
),
...
) ControlsHandlers width and heightBy default both handlers size are 35 width and height, but you can change this by FlutterSlider(
...
handlerWidth: 30,
handlerHeight: 30,
...
) Select By TapYou can tap on the slider to select it's value. FlutterSlider(
...
selectByTap: true, // default is true
...
) if you want to move your handlers by touching and moving active TrackBar, you have to set this to JumpBy default slider handlers move fluently, if you set FlutterSlider(
...
jump: true,
...
) StepThe amount the slider changes on movement can be set using FlutterSlider(
...
step: FlutterSliderStep(step: 1),
...
) Range StepIf you want to have a non-linear slider with different steps, simply use FlutterSlider(
min: 0,
max: 1000000,
...
step: FlutterSliderStep(
step: 1, // default
isPercentRange: true, // ranges are percents, 0% to 20% and so on... . default is true
rangeList: [
FlutterSliderRangeStep(from: 0, to: 20, step: 10000),
FlutterSliderRangeStep(from: 20, to: 100, step: 200000),
]
),
...
) Ignore StepsIf your configurations requires that some steps are not available, you can use FlutterSlider(
...
ignoreSteps: [
FlutterSliderIgnoreSteps(from: 8000, to: 12000),
FlutterSliderIgnoreSteps(from: 18000, to: 22000),
],
...
) Fixed ValuesIf you want to have an array of fixed items and slide through it, you can use
FlutterSlider(
...
values: [ 10, 50 ],
fixedValues: [
FlutterSliderFixedValue(percent: 0, value: "1000"),
FlutterSliderFixedValue(percent: 10, value: "10K"),
FlutterSliderFixedValue(percent: 50, value: 50000),
FlutterSliderFixedValue(percent: 80, value: "80M"),
FlutterSliderFixedValue(percent: 100, value: "100B"),
],
...
) using above example, you get when using Minimum DistanceWhen using range slider, the minimum distance between two handlers can be defined using FlutterSlider(
...
minimumDistance: 300,
...
) Maximum DistanceThis is the opposite of minimum distance, when using range slider, the maximum distance between two handlers can be defined using FlutterSlider(
...
maximumDistance: 300,
...
) Locked HandlersIf you want to lock your handlers by a certain value, you can use FlutterSlider(
...
lockHandlers: true,
lockDistance: 50,
...
) Hatch MarkYou can display a
labels alignment is center Here is an example: FlutterSlider(
...
hatchMark: FlutterSliderHatchMark(
density: 0.5, // means 50 lines, from 0 to 100 percent
labels: [
FlutterSliderHatchMarkLabel(percent: 0, label: Text('Start')),
FlutterSliderHatchMarkLabel(percent: 10, label: Text('10,000')),
FlutterSliderHatchMarkLabel(percent: 50, label: Text('50 %')),
FlutterSliderHatchMarkLabel(percent: 80, label: Text('80,000')),
FlutterSliderHatchMarkLabel(percent: 100, label: Text('Finish')),
],
),
...
) Centered OriginIf you want the value of your slider originates from center of the slider, then you can use FlutterSlider(
...
centeredOrigin: true
...
...
trackBar: FlutterSliderTrackBar(
activeTrackBar: BoxDecoration(color: trackBarColor)
),
...
...
onDragging: (handlerIndex, lowerValue, upperValue) {
if (lowerValue > (max - min) / 2) {
trackBarColor = Colors.blueAccent;
} else {
trackBarColor = Colors.redAccent;
}
setState(() {});
})
...
) Touch SizeYou can control how big a handler's touch area could be. by default touch size is 25 The range is between 5 to 50 FlutterSlider(
...
touchSize: 25,
...
) To see the touchable area for handlers, set FlutterSlider(
...
visibleTouchArea: true,
...
) Disabledto disable your slider, you can use FlutterSlider(
...
disabled: true,
...
) RTLmakes the slider FlutterSlider(
...
rtl: true,
...
) EventsThere are 3 events
All three of above functions returns three values. (int handlerIndex, dynamic lowerValue, dynamic upperValue) First value is FlutterSlider(
...
onDragging: (handlerIndex, lowerValue, upperValue) {
_lowerValue = lowerValue;
_upperValue = upperValue;
if(handlerIndex == 0)
print(" Left handler ");
setState(() {});
},
...
) Working with DatesWorking with dates are simple and straightforward. just pass standard unix timestamp as values like so: FlutterSlider(
...
values: [
new DateTime(2019,6,1,0,0,0).millisecondsSinceEpoch.toDouble(), |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论