Another Xlider 是一個可自訂的 Material Design 滑桿與範圍滑桿,適用於 Flutter,支援水平與垂直方向,並完全相容從右到左(RTL)佈局。它提供豐富的樣式、行為與互動選項,非常適合需要精確使用者輸入控制的應用程式。此套件跨平台,可在 Android、iOS、Web、macOS、Windows 與 Linux 上順暢運作。透過直覺的 API 與豐富的自訂功能,提升多樣應用環境中的 UI 一致性與使用者體驗。
適用情境
具有值選擇的表單輸入
互動式設定滑塊
可自訂範圍選擇器
RTL語言介面支援
跨平台 UI 元件
主要特色
水平與垂直滑塊支援
RTL 設計相容性
豐富的自訂選項
Material Design 相容性
支援範圍選擇
跨平台可用性
適合對象
開發國際化應用的開發者
需要靈活滑塊 UI 的設計師
需要精確輸入控制的應用程式
具有複雜表單互動的 Flutter 項目
針對多個平台的團隊
使用建議
可能需要為非 Material 主題新增額外樣式
大量實例帶來的效能影響
除了基本用法之外,文件內容有限
自訂可能會增加建構複雜性
未針對極高頻率的更新進行優化
原始 README
以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。
another_xlider
(Flutter Slider) A material design slider and range slider, horizontal and vertical, with rtl support and lots of options and customizations for flutter
IMPORTANT: Breaking Changes!
Flutter Version 2.x - Take any version up to 1.1.1
You can change the axis of your slider by setting axis to Axis.vertical. Default is horizontal
FlutterSlider(
...
axis: Axis.vertical,
...
)
Handlers
You can customize handlers using handler and rightHandler properties.
Both handler and rightHandler accept FlutterSliderHandler class which has following properties:
child: is a widget
disabled: to disable the handler
decoration, foregroundDecoration and transform are come from Container() widget
You can control the scale animation type of your handlers, it's duration and it's scale size using handlerAnimation handlerAnimation accepts a FlutterSliderHandlerAnimation class which has 4 properties as following
If you want to have a non-linear slider with different steps, simply use rangeStep feature.
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 Steps
If your configurations requires that some steps are not available, you can use ignoreSteps property.
this property accepts a simple class to define from and to ranges.
FlutterSlider(
...
ignoreSteps: [
FlutterSliderIgnoreSteps(from: 8000, to: 12000),
FlutterSliderIgnoreSteps(from: 18000, to: 22000),
],
...
)
Fixed Values
If you want to have an array of fixed items and slide through it, you can use fixedValues property. use FlutterSliderFixedValue to add your fixed values. FlutterSliderFixedValue has following properties:
percent: (int) ( between 0..100 inclusive). the position of fixed item
value: (dynamic) the value of fixed item
when using fixedValues, values of values property, must be within 0..100
using above example, you get (string) 10K as upperValue or lowerValue (depends on handler), when you reach to 10 percent of the slider,
you get (int) 50000 when you reach 50 percent of the slider and so on...
when using fixedValues, min and max are ignored
Minimum Distance
When using range slider, the minimum distance between two handlers can be defined using minimumDistance option
FlutterSlider(
...
minimumDistance: 300,
...
)
Maximum Distance
This is the opposite of minimum distance, when using range slider, the maximum distance between two handlers can be defined using maximumDistance option
FlutterSlider(
...
maximumDistance: 300,
...
)
Locked Handlers
If you want to lock your handlers by a certain value, you can use lockHandlers and lockDistance properties
You can display a Hatch Mark underneath or beside of your slider based on axis. In order to display hatch mark you must
use FlutterSliderHatchMark class which has following properties:
linesDistanceFromTrackBar: The distance of lines from slider. can be negative
bigLine: The widget of big lines in hatch mark
smallLine: The widget of small lines in hatch mark
linesAlignment: the direct of lines, right or left which works as top or bottom on horizontal slider
density: The number of lines per percent. 1 is default. any number less or more than 1 will decrease and increase lines respectively
smallDensity: The number of small lines between any two big lines. 4 is default. any number less or more than 4 will decrease and increase lines respectively.
displayLines: to display lines. by default is false for the sake of optimization
labels: If you want to display some label or text at certain percent in your hatch mark, you can use labels
labelBox: The widget of label box, however, you can define a widget for each label and have it's own style
labelsDistanceFromTrackBar: The distance of labels from slider. can be negative
disabled: to disabled the whole hatchmark ( hide )