srinivasa-dev/wheel_slider

Start and end value

Opened this issue · 3 comments

Is it possible too specify a start and end value.
Example
Start value : 10
End value : 15
10, 11, 12,13, 14, 15 are the slider options?

same issue i can't find thing would help me with start value

Is it possible too specify a start and end value. Example Start value : 10 End value : 15 10, 11, 12,13, 14, 15 are the slider options?

hey my friend, i found way to do it with .customWidget constuctor

WheelSlider.customWidget(
perspective: 0.002,
scrollPhysics: const BouncingScrollPhysics(),
totalCount: 90,
initValue: 6,
verticalListWidth: double.infinity,
customPointer: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
pointerContainer(),
Gap(calculateSelectedTextHeight(context) + 10.h),
pointerContainer(),
],
),
horizontal: false,
isInfinite: false,
isVibrate: false,
itemSize: calculateSelectedTextHeight(context),
onValueChanged: (value) {
setState(() {
context.read().currentAge = value;
});
},
children: List.generate(65, (index) {
return Align(
alignment: Alignment.center,
child: RichText(
text: TextSpan(
style: context.read().currentAge == index
? selectedNumberStyle
: TextStyle(
color: Colors.grey.withOpacity(.7),
fontSize: 24.0.sp,
fontFamily: "Cairo",
),
children: [
TextSpan(
text: (index + 18).toString(),
)
],
),
),
);
}),
),

You can solve this by

final min = 20;
final max = 200;

WheelSlider(
  horizontalListWidth: 360,
  totalCount: max - min,
  initValue: (max / 2) - min,
  isInfinite: false,
  onValueChanged: (val) {
    setState(() {
      _current = (val + min);
    });
  },
  isVibrate: false,
),