Giter VIP home page Giter VIP logo

ali-azmoud / flutter_xlider Goto Github PK

View Code? Open in Web Editor NEW
499.0 9.0 184.0 21.73 MB

A material design slider and range slider with rtl support and lots of options and customization for flutter

Home Page: https://pub.dartlang.org/packages/flutter_xlider

License: MIT License

Dart 66.66% Kotlin 0.08% Swift 0.86% Objective-C 0.42% HTML 0.99% Java 0.37% CMake 13.37% C++ 15.21% C 1.34% Shell 0.69%
range-slider vertical-slider flutter-slider

flutter_xlider's Introduction

flutter_xlider

Now supports null safety.

(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 double, its FlutterSliderStep !!

Get Started

Single Slider

A single slider

FlutterSlider(
  values: [300],
  max: 500,
  min: 0,
  onDragging: (handlerIndex, lowerValue, upperValue) {
    _lowerValue = lowerValue;
    _upperValue = upperValue;
    setState(() {});
  },
)

To make slider Right To Left use rtl: true

 FlutterSlider(
  ...
  rtl: true,
  ...
)

Range Slider

A 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 Axis

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:

  1. child: is a widget
  2. disabled: to disable the handler
  3. decoration, foregroundDecoration and transform are come from Container() widget
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 Animation

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

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 1 to scale property
if you don't want reverseCurve, just ignore it. default is null

Trackbars

To customize track bars you can use FlutterSliderTrackBar. You can see the details here

FlutterSlider(
  ...
    trackBar: FlutterSliderTrackBar(
      activeTrackBarHeight: 5,
    ),
  ...
)

inactiveTrackBarColor and activeTrackBarColor properties are removed. use inactiveTrackBar and activeTrackBar instead.

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 Widget

If you want to have a widget in the middle of your slider, you can use centralWidget

FlutterSlider(
  ...
    trackBar: FlutterSliderTrackBar(
        centralWidget: Container(
          decoration: BoxDecoration(
              color: trackBarColor,
            borderRadius: BorderRadius.circular(50)
          ),
          width: 9,
          height: 9,
        ),
    ),
  ...
)

Tooltips

In order to customize your tooltips, you can use FlutterSliderTooltip class. You can see all properties here

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 Prefix

You can use leftPrefix, leftSuffix, rightPrefix, rightSuffix to add your desired widget around tooltip content.

FlutterSlider(
  ...
    tooltip: FlutterSliderTooltip(
      leftPrefix: Icon(Icons.attach_money, size: 19, color: Colors.black45,),
      rightSuffix: Icon(Icons.attach_money, size: 19, color: Colors.black45,),
    ),
  ...
)

Tooltip Format

If you want to change the format of the value of tooltip you can use format method.

FlutterSlider(
  ...
    tooltip: FlutterSliderTooltip(
      format: (String value) {
        return value + ' ! ';
      }
    ),
  ...
)

Tooltip Callback

If you want to fully change tooltip widget and use your own customized widget, you can use custom function.

FlutterSlider(
  ...
    tooltip: FlutterSliderTooltip(
      custom: (value) {
        return Text(value.toString());
      }
    ),
  ...
)

Disable Tooltip

To disable tooltips, use disabled in FlutterSliderTooltip class

FlutterSlider(
  ...
    tooltip: FlutterSliderTooltip(
      disabled: true,
    ),
  ...
)

Tooltip Direction

To change the direction of the tooltip, you can use direction

FlutterSlider(
  ...
    tooltip: FlutterSliderTooltip(
      direction: FlutterSliderTooltipDirection.right,
    ),
  ...
)

Tooltip Position Offset

By default tooltip alignment is center, but you can modify it's top, left, right and bottom by using positionOffset

FlutterSlider(
  ...
    tooltip: FlutterSliderTooltip(
      positionOffset: FlutterSliderTooltipPositionOffset(
        top: -100
      ),
    ),
  ...
)

Always Show Tooltips

Tooltips always displayed if this property is set to true.

FlutterSlider(
  ...
  tooltip: FlutterSliderTooltip(
    alwaysShowTooltip: true,
  ),
  ...
)

Controls

Handlers width and height

By default both handlers size are 35 width and height, but you can change this by handlerWidth and handlerHeight

FlutterSlider(
  ...
  handlerWidth: 30,
  handlerHeight: 30,
  ...
)

Select By Tap

You can tap on the slider to select it's value.
if slider is range-slider, then the closest handler to the selected point will move to that point

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 false

Jump

By default slider handlers move fluently, if you set jump to true, handlers will jump between intervals

FlutterSlider(
  ...
  jump: true,
  ...
)

Step

The amount the slider changes on movement can be set using step option

FlutterSlider(
  ...
  step: FlutterSliderStep(step: 1),
  ...
)

Range Step

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:

  1. percent: (int) ( between 0..100 inclusive). the position of fixed item
  2. value: (dynamic) the value of fixed item
  • when using fixedValues, values of values property, must be within 0..100
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 (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

FlutterSlider(
  ...
    lockHandlers: true,
    lockDistance: 50,
  ...
)

Hatch Mark

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:

  1. linesDistanceFromTrackBar: The distance of lines from slider. can be negative

  2. bigLine: The widget of big lines in hatch mark

  3. smallLine: The widget of small lines in hatch mark

  4. linesAlignment: the direct of lines, right or left which works as top or bottom on horizontal slider

  5. density: The amount of lines per percent. 1 is default. any number less or more than 1 will decrease and increase lines respectively

  6. displayLines: to display lines. by default is false for the sake of optimization

  7. labels: If you want to display some label or text at certain percent in your hatch mark, you can use labels

  8. labelBox: The widget of label box, however, you can define a widget for each label and have it's own style

  9. labelsDistanceFromTrackBar: The distance of labels from slider. can be negative

  10. disabled: to disabled the whole hatchmark ( hide )

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 Origin

If you want the value of your slider originates from center of the slider, then you can use centeredOrigin property

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 Size

You 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 visibleTouchArea to true and test your slider

FlutterSlider(
  ...
  visibleTouchArea: true,
  ...
)

Disabled

to disable your slider, you can use disabled.

FlutterSlider(
  ...
  disabled: true,
  ...
)

RTL

makes the slider Right To Left

FlutterSlider(
  ...
  rtl: true,
  ...
)

Events

There are 3 events

onDragStarted: fires when drag starts
onDragCompleted fires when drag ends
onDragging keeps firing when dragging

All three of above functions returns three values.

(int handlerIndex, dynamic lowerValue, dynamic upperValue)

First value is handlerIndex, which determines the handler. 0 is Left Handler and 1 refers to Right Handler

FlutterSlider(
  ...
  onDragging: (handlerIndex, lowerValue, upperValue) {
    _lowerValue = lowerValue;
    _upperValue = upperValue;
    
    if(handlerIndex == 0)
        print(" Left handler ");
    
    setState(() {});
  },
  ...
)

Working with Dates

Working 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(), // lower date : 2019-06-01
    new DateTime(2019,9,1,0,0,0).millisecondsSinceEpoch.toDouble(), // upper date : 2019-09-01
  ],
  min: new DateTime(2019,1,1,0,0,0).millisecondsSinceEpoch.toDouble(), // start date : 2019-01-01
  max: new DateTime(2020,1,1,0,0,0).millisecondsSinceEpoch.toDouble(), // finish date : 2020-01-01
  step: FlutterSliderStep(step: 86400), // 1 day
  ...

  ...
  tooltip: FlutterSliderTooltip(
    custom: (value) {
      DateTime dtValue = DateTime.fromMillisecondsSinceEpoch(value.toInt());
      String valueInTime = dtValue.year.toString() + '-' + dtValue.month.toString() + '-' + dtValue.day.toString();
      
      return Text( valueInTime );
    }
  )
  ...

)

Showcase

It's exciting to see what you've build using this package.
Open wiki tab, create a page and share your code and image of your slider with us. Thank you

Here are some examples of what you can make using this package:

Alphabet Range
Waves
Dirty Dial
Alone in the Dark

You can find the source code in the wiki tab.

flutter_xlider's People

Contributors

abolfazlnezami2000 avatar ali-azmoud avatar angel1st avatar bgetsug avatar duy-ng-12354 avatar febg11 avatar jahngergely avatar ksomething avatar raacker avatar tlueder avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

flutter_xlider's Issues

Setting "step" to 0.1 cannot reach to max

as mentioned in #28, flutter_xlider has a UX problem that step is to be 1 by default even though values are given to double value and very makes sense to auto scale step value.

While trying to fix the problem with scaling step size, I noticed that step is only increased by 90% from min value.

for example, with min : 0, max : 1, values : [.5] params, if you start sliding from 0.0 will limit your dot at 0.9. But you can reach to 1.0 if you start from above 0.1.

no response on selectByTap

Hi,
first of all, thanks for this usefull package! :)

However, I have a problem with selectByTap: it does not make anything.
I also tried to force selectByTap to true (it shouldn't be needed, as it's true by default), but again nothing appens.
No value changed nor handler moved.

Normal "drag and drog" on the handler works well.

What's wrong?
Thanks

import 'package:flutter/material.dart';
import 'package:flutter_xlider/flutter_xlider.dart';

class DirectionAdjustment2 extends StatefulWidget {
  final Function onAdjustmentDone;
  final double startValue;
  final double height;

  DirectionAdjustment2({this.startValue, this.onAdjustmentDone, this.height});

  @override
  _DirectionAdjustment2State createState() => _DirectionAdjustment2State();
}

class _DirectionAdjustment2State extends State<DirectionAdjustment2> {
  double _value = 100;

  @override
  Widget build(BuildContext context) {
    return Container(
      height: widget.height,
      child: FlutterSlider(
        rangeSlider: false,
        min: 0,
        max: 100,
        axis: Axis.vertical,
        rtl: true,
        values: [_value],
        selectByTap: true,
        handlerWidth: 20,
        trackBar: FlutterSliderTrackBar(
          inactiveTrackBarHeight: 2,
          activeTrackBarHeight: 2,
        ),
        handler: FlutterSliderHandler(
          child: Container(),
          decoration: BoxDecoration(
              color: Theme.of(context).accentColor, shape: BoxShape.circle),
        ),
        onDragStarted: (_, __, ___) {
          // TODO add haptic feedback
          Feedback.forTap(context);
        },
        onDragCompleted: (handlerIndex, newValue, _) {
          double valueNormalized =
              num.parse((newValue / 100).toStringAsFixed(2));
          widget.onAdjustmentDone(valueNormalized);
        },
      ),
    );
  }
}

Preview
image

Unable to drag to last value

Hi, thanks for this amazing plugin!

I skimmed through the open issues but i didn't figure out a way to fix this.
The problem is that it''s very tricky to be able to select the last value of a set, this is a gif of my case:

ezgif com-video-to-gif

It doesn't matter if i'm starting the drag from 1, or if its already locked at 9 and i try lo scroll further.
The first value is always correctly reachable.

Thanks a lot again!

[Question] - How to reduce slider padding

Hi there,
First of all - thanks for the excellent package you have developed!
I have a question though - I am using the slider vertically, and since the screen width is limited, I would like to reduce the slide horizontal padding - is it possible to achieve this?

Bug, sliding far too left cause anomaly

When you place a custom FlutterSlider in a Column and you slide left too much, the widget trows an error.

I/flutter (19269): ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
I/flutter (19269): The following assertion was thrown building Container(bg: BoxDecoration(color: Color(0xffc5e1a5)),
I/flutter (19269): constraints: BoxConstraints(w=-0.7, h=5.0; NOT NORMALIZED), dirty):
I/flutter (19269): BoxConstraints has a negative minimum width.
I/flutter (19269): The offending constraints were:
I/flutter (19269):   BoxConstraints(w=-0.7, h=5.0; NOT NORMALIZED)
I/flutter (19269): 
I/flutter (19269): When the exception was thrown, this was the stack:
I/flutter (19269): #0      BoxConstraints.debugAssertIsValid.<anonymous closure>.throwError (package:flutter/src/rendering/box.dart:504:9)
I/flutter (19269): #1      BoxConstraints.debugAssertIsValid.<anonymous closure> (package:flutter/src/rendering/box.dart:532:19)
I/flutter (19269): #2      BoxConstraints.debugAssertIsValid (package:flutter/src/rendering/box.dart:551:6)
I/flutter (19269): #3      new ConstrainedBox (package:flutter/src/widgets/basic.dart:1969:27)
I/flutter (19269): #4      Container.build (package:flutter/src/widgets/container.dart:381:17)
I/flutter (19269): #5      StatelessElement.build (package:flutter/src/widgets/framework.dart:3789:28)
I/flutter (19269): #6      ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3736:15)
I/flutter (19269): #7      Element.rebuild (package:flutter/src/widgets/framework.dart:3559:5)
I/flutter (19269): #8      StatelessElement.update (package:flutter/src/widgets/framework.dart:3796:5)
I/flutter (19269): #9      Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter (19269): #10     SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4883:14)
I/flutter (19269): #11     Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter (19269): #12     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3747:16)
I/flutter (19269): #13     Element.rebuild (package:flutter/src/widgets/framework.dart:3559:5)
I/flutter (19269): #14     ProxyElement.update (package:flutter/src/widgets/framework.dart:4006:5)
I/flutter (19269): #15     Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter (19269): #16     RenderObjectElement.updateChildren (package:flutter/src/widgets/framework.dart:4601:32)
I/flutter (19269): #17     MultiChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4992:17)
I/flutter (19269): #18     Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter (19269): #19     SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4883:14)
I/flutter (19269): #20     Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter (19269): #21     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3747:16)
I/flutter (19269): #22     Element.rebuild (package:flutter/src/widgets/framework.dart:3559:5)
I/flutter (19269): #23     StatelessElement.update (package:flutter/src/widgets/framework.dart:3796:5)
I/flutter (19269): #24     Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter (19269): #25     _LayoutBuilderElement._layout.<anonymous closure> (package:flutter/src/widgets/layout_builder.dart:118:18)
I/flutter (19269): #26     BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2253:19)
I/flutter (19269): #27     _LayoutBuilderElement._layout (package:flutter/src/widgets/layout_builder.dart:107:11)
I/flutter (19269): #28     RenderObject.invokeLayoutCallback.<anonymous closure> (package:flutter/src/rendering/object.dart:1728:58)
I/flutter (19269): #29     PipelineOwner._enableMutationsToDirtySubtrees (package:flutter/src/rendering/object.dart:797:15)
I/flutter (19269): #30     RenderObject.invokeLayoutCallback (package:flutter/src/rendering/object.dart:1728:13)
I/flutter (19269): #31     _RenderLayoutBuilder.performLayout (package:flutter/src/widgets/layout_builder.dart:205:5)
I/flutter (19269): #32     RenderObject.layout (package:flutter/src/rendering/object.dart:1632:7)
I/flutter (19269): #33     RenderPadding.performLayout (package:flutter/src/rendering/shifted_box.dart:199:11)
I/flutter (19269): #34     RenderObject.layout (package:flutter/src/rendering/object.dart:1632:7)
I/flutter (19269): #35     RenderFlex.performLayout (package:flutter/src/rendering/flex.dart:738:15)
I/flutter (19269): #36     RenderObject.layout (package:flutter/src/rendering/object.dart:1632:7)
I/flutter (19269): #37     MultiChildLayoutDelegate.layoutChild (package:flutter/src/rendering/custom_layout.dart:142:11)
I/flutter (19269): #38     _ScaffoldLayout.performLayout (package:flutter/src/material/scaffold.dart:350:7)
I/flutter (19269): #39     MultiChildLayoutDelegate._callPerformLayout (package:flutter/src/rendering/custom_layout.dart:212:7)
I/flutter (19269): #40     RenderCustomMultiChildLayoutBox.performLayout (package:flutter/src/rendering/custom_layout.dart:356:14)
I/flutter (19269): #41     RenderObject._layoutWithoutResize (package:flutter/src/rendering/object.dart:1507:7)
I/flutter (19269): #42     PipelineOwner.flushLayout (package:flutter/src/rendering/object.dart:766:18)
I/flutter (19269): #43     _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding.drawFrame (package:flutter/src/rendering/binding.dart:329:19)
I/flutter (19269): #44     _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding&WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:701:13)
I/flutter (19269): #45     _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:268:5)
I/flutter (19269): #46     _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:988:15)
I/flutter (19269): #47     _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:928:9)
I/flutter (19269): #48     _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:840:5)
I/flutter (19269): #52     _invoke (dart:ui/hooks.dart:209:10)
I/flutter (19269): #53     _drawFrame (dart:ui/hooks.dart:168:3)
I/flutter (19269): (elided 3 frames from package dart:async)

Possible fix:

Positioned _rightInactiveTrack() {
    double top, bottom, left, right, width, height;
    top = left = width = height = 0;
    right = bottom = null;

    if (widget.axis == Axis.horizontal) {
      bottom = 0;
      height = widget.trackBar.inactiveTrackBarHeight;
      print("here 6");
      width = _constraintMaxWidth -
          _rightHandlerXPosition -
          _handlersPadding -
          (widget.touchZone * 20 / 2);

      print("width "+width.toString());
      print("_rightHandlerXPosition "+_rightHandlerXPosition.toString());
      //BUGFIX HERE
      if(_rightHandlerXPosition<0){
         //FORCE ZERO
        _rightHandlerXPosition=0;
      }
      //FORCE 0 (not sure if it's necessary but still 
      if( _rightHandlerXPosition + (widget.touchZone * 20 / 2)>0) {
        left = _rightHandlerXPosition + (widget.touchZone * 20 / 2);
      }else{
        left =0;
      }
      print("left "+left.toString());
      if(left<0){
        left = 0;
      }
      print("left "+left.toString());
    } else {
      right = 0;
      width = widget.trackBar.inactiveTrackBarHeight;
      height = _constraintMaxHeight -
          _rightHandlerYPosition -
          _handlersPadding -
          (widget.touchZone * 20 / 2);
      top = _rightHandlerYPosition + (widget.touchZone * 20 / 2);
    }

//    if (widget.rangeSlider == true)
//      width = _constraintMaxWidth -
//          _rightHandlerXPosition -
//          _handlersPadding -
//          (widget.touchZone * 20 / 2);

    return Positioned(
      left: left,
      top: top,
      bottom: bottom,
      right: right,
      child: Center(
        child: Container(
          height: height,
          width: width,
          color: widget.trackBar.rightInactiveTrackBarColor,
        ),
      ),
    );
  }

Override Tooltip

Hello,
I've been using your range slider for a while and i've tried to customize it, but i'm getting stuck at the tooltip customization.
The thing is, is is possible to override it's display and put instead a CostumPainter object? I wanted to be able to fully paint a non-box object in the tooltip position...

Also, is it possible to implement an easy way to edit the decoration of the unselected track bar? I wanted to round the corners, but it's impossible without editing yout plugin's source code...

So, is it possible to do so?
Thanks, and great job with the plugin ;)

Exception will occur with minimumDistance and double-precision floating-point errors.

If the difference between the lower and upper value is a little bit off due to double-precision floating-point errors, (ex. 0.6 - 0.5 == 0.09999999999999998), and the minimumDistance is slightly bigger (ex. 0.1), then an exception will be thrown. There needs to be an edge case handler for this, like an maximum epsilon value to account for the error.

cannot change thumb value

Hi, i want to change the move the slider value programatically using the values property but it doesn't work. any ideas why?

FlutterSlider(
    values: [_test],
    min: 500000,
    max: 1000000,
    step: 100000,
    onDragging: (handlerIndex, lowerValue, upperValue) {    
    },
),
FlatButton(
  onPressed: () {
    setState(() {
      _test = 800000;
    });
  },
  child: Text('Press me'),
),

Issues with rangeSlider

We encountered two issues with ranged Slider :

1 - The handles seems not horizontally aligned (see below, I added a red line, the right one seems 1 point below the left one)
I can reproduce this with default handlers, and also with custom ones.
Screenshot_20190813-143756
Screenshot 2019-08-13 at 14 49 18

Row( children: <Widget>[ Expanded( child: FlutterSlider( values: [0, 10], rangeSlider: true, min: 0, max: 100, ), ) ] ),

2 - When scrolling quickly one handle directly beyond the other one, sometimes it does not go to its maximum possible value.

called on null

hi! when I run your code in example file it has this error : the getter 'boxstyle' was called on null.whats the problem??

Conflict with flutter_localizations

I tried to include your widget but received the following error:

Because flutter_xlider >=2.5.3 depends on intl ^0.16.0 and every version of flutter_localizations from sdk depends on intl 0.15.8, flutter_xlider >=2.5.3 is incompatible with flutter_localizations from sdk.
So, because localmarketsapp depends on both flutter_localizations any from sdk and flutter_xlider ^2.5.3, version solving failed.

Compiling error on 2.4.0

After updating to 2.4.0, I got this message when trying to run on Android device :

Compiler message:
...workspace_flutter/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_xlider-2.4.0/lib/flutter_xlider.dart:468:42: Error: Getter not found: 'visible'.
overflow: TextOverflow.visible,

Exception when i let go of scrolling

When i let go of the scroller i get this exception

════════ Exception caught by widgets library ═══════════════════════════════════════════════════════
The following assertion was thrown while finalizing the widget tree:
_FlutterSliderState#30df9(tickers: tracking 4 tickers) was disposed with an active Ticker.

_FlutterSliderState created a Ticker via its TickerProviderStateMixin, but at the time dispose() was called on the mixin, that Ticker was still active. All Tickers must be disposed before calling super.dispose().

Tickers used by AnimationControllers should be disposed by calling dispose() on the AnimationController itself. Otherwise, the ticker will leak.

The offending ticker was: _WidgetTicker(created by _FlutterSliderState#30df9(lifecycle state: created, tickers: tracking 0 tickers))
The stack trace when the _WidgetTicker was actually created was:
#0      new Ticker.<anonymous closure> (package:flutter/src/scheduler/ticker.dart:66:40)
#1      new Ticker (package:flutter/src/scheduler/ticker.dart:68:6)
#2      new _WidgetTicker (package:flutter/src/widgets/ticker_provider.dart:237:80)
#3      TickerProviderStateMixin.createTicker (package:flutter/src/widgets/ticker_provider.dart:168:34)
#4      new AnimationController (package:flutter/src/animation/animation_controller.dart:245:21)
#5      _FlutterSliderState.initMethod (package:flutter_xlider/flutter_xlider.dart:342:46)
#6      _FlutterSliderState.initState (package:flutter_xlider/flutter_xlider.dart:253:5)
#7      StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:4355:58)
#8      ComponentElement.mount (package:flutter/src/widgets/framework.dart:4201:5)
#9      Element.inflateWidget (package:flutter/src/widgets/framework.dart:3194:14)
#10     Element.updateChild (package:flutter/src/widgets/framework.dart:2988:12)
#11     SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:5445:14)
#12     Element.inflateWidget (package:flutter/src/widgets/framework.dart:3194:14)
#13     Element.updateChild (package:flutter/src/widgets/framework.dart:2988:12)
#14     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4243:16)
#15     Element.rebuild (package:flutter/src/widgets/framework.dart:3947:5)
#16     ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:4206:5)
#17     ComponentElement.mount (package:flutter/src/widgets/framework.dart:4201:5)
#18     Element.inflateWidget (package:flutter/src/widgets/framework.dart:3194:14)
#19     Element.updateChild (package:flutter/src/widgets/framework.dart:2988:12)
#20     SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:5445:14)
#21     Element.inflateWidget (package:flutter/src/widgets/framework.dart:3194:14)
#22     Element.updateChild (package:flutter/src/widgets/framework.dart:2988:12)
#23     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4243:16)
#24     Element.rebuild (package:flutter/src/widgets/framework.dart:3947:5)
#25     ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:4206:5)
#26     ComponentElement.mount (package:flutter/src/widgets/framework.dart:4201:5)
#27     Element.inflateWidget (package:flutter/src/widgets/framework.dart:3194:14)
#28     Element.updateChild (package:flutter/src/widgets/framework.dart:2988:12)
#29     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4243:16)
#30     Element.rebuild (package:flutter/src/widgets/framework.dart:3947:5)
#31     ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:4206:5)
#32     ComponentElement.mount (package:flutter/src/widgets/framework.dart:4201:5)
#33     ParentDataElement.mount (package:flutter/src/widgets/framework.dart:4617:11)
#34     Element.inflateWidget (package:flutter/src/widgets/framework.dart:3194:14)
#35     MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:5551:32)
#36     Element.inflateWidget (package:flutter/src/widgets/framework.dart:3194:14)
#37     Element.updateChild (package:flutter/src/widgets/framework.dart:2988:12)
#38     SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:5445:14)
#39     Element.inflateWidget (package:flutter/src/widgets/framework.dart:3194:14)
#40     Element.updateChild (package:flutter/src/widgets/framework.dart:2988:12)
#41     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4243:16)
#42     Element.rebuild (package:flutter/src/widgets/framework.dart:3947:5)
#43     ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:4206:5)
#44     ComponentElement.mount (package:flutter/src/widgets/framework.dart:4201:5)
#45     Element.inflateWidget (package:flutter/src/widgets/framework.dart:3194:14)
#46     Element.updateChild (package:flutter/src/widgets/framework.dart:2988:12)
#47     SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:5445:14)
#48     Element.inflateWidget (package:flutter/src/widgets/framework.dart:3194:14)
#49     Element.updateChild (package:flutter/src/widgets/framework.dart:2988:12)
#50     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4243:16)
#51     Element.rebuild (package:flutter/src/widgets/framework.dart:3947:5)
#52     ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:4206:5)
#53     ComponentElement.mount (package:flutter/src/widgets/framework.dart:4201:5)
#54     Element.inflateWidget (package:flutter/src/widgets/framework.dart:3194:14)
#55     Element.updateChild (package:flutter/src/widgets/framework.dart:2988:12)
#56     SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:5445:14)
#57     Element.inflateWidget (package:flutter/src/widgets/framework.dart:3194:14)
#58     Element.updateChild (package:flutter/src/widgets/framework.dart:2988:12)
#59     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4243:16)
#60     Element.rebuild (package:flutter/src/widgets/framework.dart:3947:5)
#61     ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:4206:5)
#62     ComponentElement.mount (package:flutter/src/widgets/framework.dart:4201:5)
#63     Element.inflateWidget (package:flutter/src/widgets/framework.dart:3194:14)
#64     Element.updateChild (package:flutter/src/widgets/framework.dart:2988:12)
#65     RenderObjectElement.updateChildren (package:flutter/src/widgets/framework.dart:5219:32)
#66     MultiChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:5561:17)
#67     Element.updateChild (package:flutter/src/widgets/framework.dart:2977:15)
#68     SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:5452:14)
#69     Element.updateChild (package:flutter/src/widgets/framework.dart:2977:15)
#70     SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:5452:14)
#71     Element.updateChild (package:flutter/src/widgets/framework.dart:2977:15)
#72     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4243:16)
#73     Element.rebuild (package:flutter/src/widgets/framework.dart:3947:5)
#74     StatelessElement.update (package:flutter/src/widgets/framework.dart:4298:5)
#75     Element.updateChild (package:flutter/src/widgets/framework.dart:2977:15)
#76     RenderObjectElement.updateChildren (package:flutter/src/widgets/framework.dart:5161:32)
#77     MultiChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:5561:17)
#78     Element.updateChild (package:flutter/src/widgets/framework.dart:2977:15)
#79     SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:5452:14)
#80     Element.updateChild (package:flutter/src/widgets/framework.dart:2977:15)
#81     RenderObjectElement.updateChildren (package:flutter/src/widgets/framework.dart:5161:32)
#82     MultiChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:5561:17)
#83     Element.updateChild (package:flutter/src/widgets/framework.dart:2977:15)
#84     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4243:16)
#85     Element.rebuild (package:flutter/src/widgets/framework.dart:3947:5)
#86     StatefulElement.update (package:flutter/src/widgets/framework.dart:4413:5)
#87     Element.updateChild (package:flutter/src/widgets/framework.dart:2977:15)
#88     SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:5452:14)
#89     Element.updateChild (package:flutter/src/widgets/framework.dart:2977:15)
#90     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4243:16)
#91     Element.rebuild (package:flutter/src/widgets/framework.dart:3947:5)
#92     StatelessElement.update (package:flutter/src/widgets/framework.dart:4298:5)
#93     Element.updateChild (package:flutter/src/widgets/framework.dart:2977:15)
#94     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4243:16)
#95     Element.rebuild (package:flutter/src/widgets/framework.dart:3947:5)
#96     BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2432:33)
#97     WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:773:20)
#98     RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:283:5)
#99     SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1102:15)
#100    SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1041:9)
#101    SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:957:5)
#105    _invoke (dart:ui/hooks.dart:259:10)
#106    _drawFrame (dart:ui/hooks.dart:217:3)
(elided 3 frames from package dart:async)

When the exception was thrown, this was the stack: 
#0      TickerProviderStateMixin.dispose.<anonymous closure> (package:flutter/src/widgets/ticker_provider.dart:185:13)
#1      TickerProviderStateMixin.dispose (package:flutter/src/widgets/ticker_provider.dart:203:6)
#2      StatefulElement.unmount (package:flutter/src/widgets/framework.dart:4435:12)
#3      _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1748:13)
#4      _InactiveElements._unmount.<anonymous closure> (package:flutter/src/widgets/framework.dart:1746:7)
...

Very hard to drag slider to max value

Somehow it's very hard to drag to max value.
(tested on ios simulator and device, haven't tried on android).

Here is the vid in ios simulator (i'm clicking the mouse and drag it, however it cannot reach max value)
1

FlutterSlider(
    jump: true,
    tooltip: FlutterSliderTooltip(
        disabled: true,
    ),
    trackBar: FlutterSliderTrackBar(
        activeTrackBarColor: Colors.blue[500],
    ),
    handler: FlutterSliderHandler(
        child: Container(
            width: 32,
            height: 32,
            decoration: new BoxDecoration(
                border: Border.all(color: Colors.blue, width: 3),
                color: Colors.white,
                shape: BoxShape.circle,
            ),
        ),
    ),
    values: [500000],
    min: 100000,
    max: 1000000,
    step: 100000,
    onDragging: (handlerIndex, lowerValue, upperValue) {
    },
)

How to set the value of the slider

Hello, is there a way to externally specify the slider's current position? Maybe... in the following way,

GlobalKey<FlutterSliderState> _sliderKey = GlobalKey<FlutterSliderState>();
_sliderKey.currentState.setSliderValue(100);

When A and B sliders needed to move together, I couldn't find a way to implement them without modifying flutter_xlider's code (when B sliders had to be synchronized to A and vice versa).

Error when in TabBar

When placed in TabBar I get the following error when swiping from the tab with FlutterSlider to another tab.

════════ Exception caught by scheduler library ═════════════════════════════════
The following assertion was thrown during a scheduler callback:
'package:flutter/src/widgets/media_query.dart': Failed assertion: line 791 pos 12: 'context != null': is not true.

Either the assertion indicates an error in the framework itself, or we should provide substantially more information in this error message to help you determine and fix the underlying cause.
In either case, please report this assertion by filing a bug on GitHub:
https://github.com/flutter/flutter/issues/new?template=BUG.md

When the exception was thrown, this was the stack
#2 MediaQuery.of
package:flutter/…/widgets/media_query.dart:791
#3 _FlutterSliderState._renderBoxInitialization (package:flutter_xlider/flutter_xlider.dart:2025:21)
#4 _FlutterSliderState.initMethod. (package:flutter_xlider/flutter_xlider.dart:407:7)
#5 SchedulerBinding._invokeFrameCallback
package:flutter/…/scheduler/binding.dart:1102
#6 SchedulerBinding.handleDrawFrame
package:flutter/…/scheduler/binding.dart:1049
...

xlider for Flutter web

This is more of a request than an issue.
I would like to use flutter_xlider for the Flutter web too.

Currently, when compiled, it gives the error:
Another exception was thrown: RangeError (index): Index out of range: index should be less than 1: 1
The same code works fine on mobile.

Build AppBundle : "Error: No named parameter with the name 'activeTrackBarColor'.activeTrackBarColor: Colors.red"

i try to build AppBundle, but get below error :

zukinarus-Air:xpress zukinaru$ flutter build appbundle --release
Initializing gradle...                                              2.5s
Resolving dependencies...                                           5.4s
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
                                                                        
Compiler message:                                                       
lib/src/ui/playlist-song/now_playing_screen.dart:163:53: Error: No named parameter with the name 'activeTrackBarColor'.
                                                    activeTrackBarColor: Colors.red
                                                    ^^^^^^^^^^^^^^^^^^^ 
file:///Users/zukinaru/development/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_xlider-2.4.5/lib/flutter_xlider.dart:1600:9: Context: Found this candidate, but the arguments don't match.
  const FlutterSliderTrackBar({                                         
        ^                                                               
Compiler terminated unexpectedly.                                       
                                                                        
FAILURE: Build failed with an exception.                                
                                                                        
* Where:                                                                
Script '/Users/zukinaru/development/flutter/packages/flutter_tools/gradle/flutter.gradle' line: 638
                                                                        
* What went wrong:                                                      
Execution failed for task ':app:compileflutterBuildReleaseArm'.         
> Process 'command '/Users/zukinaru/development/flutter/bin/flutter'' finished with non-zero exit value 1
                                                                        
* Try:                                                                  
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
                                                                        
* Get more help at https://help.gradle.org                              
                                                                        
BUILD FAILED in 19s                                                     
Running Gradle task 'bundleRelease'...                                  
Running Gradle task 'bundleRelease'... Done                        20.2s
Gradle task bundleRelease failed with exit code 1
zukinarus-Air:xpress zukinaru$ 

Moreover, a copy of this project build successfully but it use flutter_xlide-2.4.3

One Strange problem...

i set what packages to be imported on pubspec.yaml. On this case i try to import flutter_xlide-2.4.3 ( sometime i change to flutter_xlide-2.4.2). But why the library imported to my development folder (/Users/zukinaru/development/flutter/.pub-cache/hosted/pub.dartlang.org) always come with flutter_xlide-2.4.5 ?

Steps to reproduce ( on wrong version packages ) :

  1. set 'flutter_xlide-2.4.2atpubspec.yaml`
  2. run 'flutter packaget get` on your project folder
  3. check flutter development folder at development/flutter/.pub-cache/hosted/pub.dartlang.org
  4. ls -l and find flutter_xlide-*' you will find flutter_xlide-2.4.5, it should be flutter_xlide-2.4.2`

Update

Build successfully if using flutter_xlider-2.4.2 but for now, I cant use build service at codemagic.io, because they always download dependencies with flutter_xlider-2.4.5 even i have set flutter_xlide-2.4.2 at pubspec.yaml

when add attribute axis: Axis.vertical ,throw error

when i write the code like :
FlutterSlider( values: [10], axis: Axis.vertical, max: 100, min: 0, 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)), ), )

throw error


�[38;5;248m════════ Exception caught by rendering library ═════════════════════════════════�[39;49m
�[38;5;244mThe following assertion was thrown during performLayout():�[39;49m
BoxConstraints forces an infinite height.

�[38;5;244mThese invalid constraints were provided to RenderPadding's layout() function by the following function, which probably computed the invalid constraints in question:
RenderConstrainedBox.performLayout (package:flutter/src/rendering/proxy_box.dart:259:13)
�[39;49m�[38;5;244mThe offending constraints were: BoxConstraints(w=63.0, h=Infinity)�[39;49m
�[38;5;244mUser-created ancestor of the error-causing widget was�[39;49m
�[38;5;248mFlutterSlider�[39;49m
�[38;5;244mWhen the exception was thrown, this was the stack�[39;49m
�[38;5;244m#0 BoxConstraints.debugAssertIsValid..throwError�[39;49m
�[38;5;244m#1 BoxConstraints.debugAssertIsValid.�[39;49m
�[38;5;244m#2 BoxConstraints.debugAssertIsValid�[39;49m
�[38;5;244m#3 RenderObject.layout�[39;49m
�[38;5;244m#4 RenderConstrainedBox.performLayout�[39;49m
�[38;5;244m...�[39;49m
�[38;5;244mThe following RenderObject was being processed when the exception was fired: RenderConstrainedBox#3b389 relayoutBoundary=up4 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE�[39;49m
�[38;5;244mRenderObject: RenderConstrainedBox#3b389 relayoutBoundary=up4 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE�[39;49m
�[38;5;244mparentData: offset=Offset(0.0, 0.0) (can use size)�[39;49m
�[38;5;244mconstraints: BoxConstraints(0.0<=w<=414.0, 0.0<=h<=Infinity)�[39;49m
�[38;5;244msize: Size(414.0, 63.0)�[39;49m
�[38;5;244madditionalConstraints: BoxConstraints(w=63.0, h=Infinity)�[39;49m
�[38;5;244mchild: RenderPadding#f850f NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE�[39;49m
�[38;5;244mparentData: (can use size)�[39;49m
�[38;5;244mconstraints: BoxConstraints(w=414.0, h=63.0)�[39;49m
�[38;5;244msize: Size(414.0, 63.0)�[39;49m
�[38;5;244mpadding: EdgeInsets(17.5, 17.5, 0.0, 0.0)�[39;49m
�[38;5;244mtextDirection: ltr�[39;49m
�[38;5;244mchild: RenderStack#7afda NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE�[39;49m
�[38;5;244mparentData: offset=Offset(17.5, 17.5) (can use size)�[39;49m
�[38;5;244mconstraints: BoxConstraints(w=396.5, h=45.5)�[39;49m
�[38;5;244msize: Size(396.5, 45.5)�[39;49m
�[38;5;244malignment: AlignmentDirectional.topStart�[39;49m
�[38;5;244mtextDirection: ltr�[39;49m
�[38;5;244mfit: loose�[39;49m
�[38;5;244moverflow: visible�[39;49m
�[38;5;244mchild 1: RenderPositionedBox#c3107 relayoutBoundary=up1 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE�[39;49m
�[38;5;244mparentData: top=17.5; right=0.0; left=0.0; offset=Offset(0.0, 17.5) (can use size)�[39;49m
�[38;5;244mconstraints: BoxConstraints(w=396.5, 0.0<=h<=Infinity)�[39;49m
�[38;5;244msize: Size(396.5, 3.0)�[39;49m
�[38;5;244malignment: center�[39;49m
�[38;5;244mtextDirection: ltr�[39;49m
�[38;5;244mwidthFactor: expand�[39;49m
�[38;5;244mheightFactor: expand�[39;49m
�[38;5;244mchild: RenderConstrainedBox#9820f relayoutBoundary=up2 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE�[39;49m
�[38;5;244mparentData: offset=Offset(26.3, 0.0) (can use size)�[39;49m
�[38;5;244mconstraints: BoxConstraints(0.0<=w<=396.5, 0.0<=h<=Infinity)�[39;49m
�[38;5;244msize: Size(344.0, 3.0)�[39;49m
�[38;5;244madditionalConstraints: BoxConstraints(w=3.0, h=Infinity)�[39;49m
�[38;5;244mchild 2: RenderPositionedBox#f3ee4 relayoutBoundary=up1 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE�[39;49m
�[38;5;244mparentData: top=31.5; right=0.0; left=0.0; offset=Offset(0.0, 31.5) (can use size)�[39;49m
�[38;5;244mconstraints: BoxConstraints(w=396.5, 0.0<=h<=Infinity)�[39;49m
�[38;5;244msize: Size(396.5, 1.0)�[39;49m
�[38;5;244malignment: center�[39;49m
�[38;5;244mtextDirection: ltr�[39;49m
�[38;5;244mwidthFactor: expand�[39;49m
�[38;5;244mheightFactor: expand�[39;49m
�[38;5;244mchild: RenderConstrainedBox#89c2d relayoutBoundary=up2 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE�[39;49m
�[38;5;244mparentData: offset=Offset(196.5, 0.0) (can use size)�[39;49m
�[38;5;244mconstraints: BoxConstraints(0.0<=w<=396.5, 0.0<=h<=Infinity)�[39;49m
�[38;5;244msize: Size(3.5, 1.0)�[39;49m
�[38;5;244madditionalConstraints: BoxConstraints(w=3.5, h=1.0)�[39;49m
�[38;5;244mchild 3: RenderOpacity#3bd0f NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE�[39;49m
�[38;5;244mparentData: top=0.0; right=0.0; bottom=0.0; left=0.0; offset=Offset(0.0, 0.0) (can use size)�[39;49m
�[38;5;244mconstraints: BoxConstraints(w=396.5, h=45.5)�[39;49m
�[38;5;244msize: Size(396.5, 45.5)�[39;49m
�[38;5;244mopacity: 0.0�[39;49m
�[38;5;244mchild: RenderPointerListener#c2553 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE�[39;49m
�[38;5;244mparentData: (can use size)�[39;49m
�[38;5;244mconstraints: BoxConstraints(w=396.5, h=45.5)�[39;49m
�[38;5;244msize: Size(396.5, 45.5)�[39;49m
�[38;5;244mbehavior: deferToChild�[39;49m
�[38;5;244mlisteners: down�[39;49m
�[38;5;244mchild 4: RenderLimitedBox#473e7 relayoutBoundary=up1 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE�[39;49m
�[38;5;244mparentData: not positioned; offset=Offset(0.0, 0.0) (can use size)�[39;49m
�[38;5;244mconstraints: BoxConstraints(0.0<=w<=396.5, 0.0<=h<=45.5)�[39;49m
�[38;5;244msize: Size(396.5, 45.5)�[39;49m
�[38;5;244mmaxWidth: 0.0�[39;49m
�[38;5;244mmaxHeight: 0.0�[39;49m
�[38;5;244mchild: RenderConstrainedBox#09de0 relayoutBoundary=up2 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE�[39;49m
�[38;5;244mparentData: (can use size)�[39;49m
�[38;5;244mconstraints: BoxConstraints(0.0<=w<=396.5, 0.0<=h<=45.5)�[39;49m
�[38;5;244msize: Size(396.5, 45.5)�[39;49m
�[38;5;244madditionalConstraints: BoxConstraints(biggest)�[39;49m
�[38;5;244mchild 5: RenderPointerListener#f31f4 relayoutBoundary=up1 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE�[39;49m
�[38;5;244mparentData: top=0.0; right=0.0; left=278.4; offset=Offset(278.4, 0.0) (can use size)�[39;49m
�[38;5;244mconstraints: BoxConstraints(w=118.1, 0.0<=h<=Infinity)�[39;49m
�[38;5;244msize: Size(118.1, 65.0)�[39;49m
�[38;5;244mbehavior: deferToChild�[39;49m
�[38;5;244mlisteners: down, move, up�[39;49m
�[38;5;244mchild: RenderPointerListener#faa4b relayoutBoundary=up2 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE�[39;49m
�[38;5;244mparentData: (can use size)�[39;49m
�[38;5;244mconstraints: BoxConstraints(w=118.1, 0.0<=h<=Infinity)�[39;49m
�[38;5;244msize: Size(118.1, 65.0)�[39;49m
�[38;5;244mbehavior: deferToChild�[39;49m
�[38;5;244mlisteners: down�[39;49m
�[38;5;248m════════════════════════════════════════════════════════════════════════════════�[39;49m

�[38;5;248m════════ Exception caught by rendering library ═════════════════════════════════�[39;49m
BoxConstraints forces an infinite height.
�[38;5;244mUser-created ancestor of the error-causing widget was�[39;49m
�[38;5;248mFlutterSlider�[39;49m
�[38;5;248m════════════════════════════════════════════════════════════════════════════════�[39;49m
Reloaded 4 of 612 libraries in 427ms.

Glitch on dragging thumb

Here the code and video of some glitches I found :

  • Strange "jumping artefact"
  • Difficult to go to the last value

On iOS device and emulator.

Glitch_xlider_flutter

FlutterSlider( values: [_selectorValue.toDouble()], touchSize: 30, jump: false, max: 5, min: 1, axis: Axis.vertical, onDragging: (handlerIndex, lowerValue, upperValue) { setState(() { _selectorValue = lowerValue.toInt(); }); }, ),

"The method 'toDouble' was called on null" when using fixedValues

Here is the code where the error occured. Does this is a bug or i am using on wrong way?

  void didUpdateWidget(FlutterSlider oldWidget) {
    bool lowerValueNotEquality = oldWidget.values[0] != widget.values[0];
    bool upperValueNotEquality =
        (widget.values.length > 1 && oldWidget.values[1] != widget.values[1]);

    _widgetMax = widget.max;
    _widgetMin = widget.min;

    /// _widgetMax and _widgetMin are null
    bool lowerValueValidation =
        (widget.values[0] >= _widgetMin && widget.values[0] <= _widgetMax);
    ...
}

The code where i am using fluter_xlider widget:

FlutterSlider(
   jump: false,
   values: const [20],
   tooltip: FlutterSliderTooltip(
      alwaysShowTooltip: true,
   ),
   fixedValues: [
    FlutterSliderFixedValue(percent: 0, value: 1),
    FlutterSliderFixedValue(percent: 10, value: 2),
    FlutterSliderFixedValue(percent: 20, value: 3),
    FlutterSliderFixedValue(percent: 30, value: 4),
  ],
   onDragging: (handlerIndex, lowerValue, upperValue) => validDays = lowerValue as int,
 )

Slider Tap to select value doesn't trigger onDragCompleted event

Currently, only the onDragging event is triggered when tapping the slider to select the value, is it possible to add the tap to trigger the onDragCompleted event? I am using the call back to update a list count after an API call and don't want to add the onDragging event to constantly keep calling the API?
Love the package so far!

Tooltip doesn't show values from 0 to 1

With the following settings the tool tip doesn't change from 0.0 until it reaches one.

returnWidget = new FlutterSlider(
              values: [.5],
              min: 0,
              max: 1.0,
              handler: new FlutterSliderHandler(
                child: _determineIcon(index)
              ),
              onDragCompleted: (handlerIndex, lowerValue, upperValue) {

Losing the slider thumb on changing phone orientation

Hey, great job.

I have small issue:

import 'package:flutter/material.dart';
import 'package:flutter_xlider/flutter_xlider.dart';

void main() async {
  runApp(
    MaterialApp(
        home: Scaffold(
      backgroundColor: Colors.grey,
      body: Center(child: Test()),
    )),
  );
}

class Test extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    var isPortrait = MediaQuery.of(context).orientation == Orientation.portrait;

    return FlutterSlider(
      axis: isPortrait ? Axis.horizontal : Axis.vertical,
      values: [5],
      max: 10,
      min: 0,
      onDragging: (handlerIndex, lowerValue, upperValue) {},
    );
  }
}

ezgif com-optimize

How to return to original value/position using onDragCompleted()

Hi, thank you for this very useful package. I'm just new to Flutter and I'm not sure if I just don't know how to implement it in general, but may I know how to set the slider to it's original value and position using onDragCompleted()?
I'm using the slider as part of a Car Remote Control that can do forward/reverse using 1 slider and another for left and right. I need a back-to-center functionality once I completed dragging the slider on either direction.

How to remove chevron icons?

Hi, nice plugin!
It's very easy to use, but how can we remove chevron (chevron_left and chevron_right) default icons on handlers without making new handler? Is there an easy way?

License?

This looks very interesting. Thanks for sharing it.

What is the license it is being released under?

How to handle orientation change

Hey,
it seems that the way that the slider reacts on orientation change can be improved. Right now, when changing from portrait to landscape, the active trackbar remains the same size while the full trackbar adapt itself to the new size of the screen.

xlider-portait-to-landscape

When turning from landscape to portait, the active trackbar remains the same size as well, causing the active trackbar to be out of the screen (however, a tap on the active bar fixes the problem).

xlider-landscape-to-portrait

tooltip

im trying to display time instead of numbers with decimals. im using the xlider for a media player, is it possible to format the values to be in time instead of integers? and with a colon separator between the minutes and seconds?

selectByTap not working properly

when tap on the slider, value not updating on first tap and some times showing wrong values which is not appropriate for the current slider tracker position.

_drawHatchMark throws exception at some edge case

Hi there,
I believe I found out an issue, when using the slider. It is quite an edge case and I cannot isolate it in minimum reproducing sample, however, I debugged it and I will try to explain the case:

The issue appears in case hatchMark is set.

In case the slider is on app home page, at some point _drawHatchMark is called. Within it however, at lines 461 to 465, the slider uses _constraintMaxHeight and _constraintMaxWidth for its internal calculations.
These two class members however are initialized at lines 605 and 606 within build method.

In my edge case, however, _drawHatchMark is called from didUpdateWidget which as I believe you are familiar is actually called prior build method.
In summary - when _drawHatchMark is called the above two class members are null, hence the calculations failed.

I hope the above will give you an idea about the case and how to fix it.

Thanks for the excellent widget and I look forward to hearing from you!

Updated
Actually commented out _drawHatchMark call from didUpdateWidget (line 592) seems to fix the issue, I would however leave to you to decide if this is the ulitmate fix.

slider height not up to it's content

Slider is cut off from top and bottom portion. It's not showing Tooltip and Thumb properly.
here is the code I have in body

      body: Center(
          child: SingleChildScrollView(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              FlutterSlider(
                values: [100],
                max: 500,
                min: 0,
                handlerAnimation: FlutterSliderHandlerAnimation(
                  curve: Curves.elasticOut,
                  reverseCurve: null,
                  duration: Duration(milliseconds: 700),
                  scale: 1.4,
                ),
                onDragging: (handlerIndex, lowerValue, upperValue) {
                  setState(() {});
                },
              ),
            ],
          ),
        ),
      ),

Here is the attachment to make it more clear.
Simulator Screen Shot - iPhone XS Max - 2019-06-10 at 15 44 47

Vertical page scroll moves horizontal scroller

Hi Ali, not sure if this is fixable in any way, but it creates a bit dodgy effect.

When i set a value, then scroll the page down, if i happen to start the drag gesture on the bar the handler is moved to that position, the value is not changed tho. This is a video of the issue

ezgif com-video-to-gif(1)

how to get decimal points from the slider?

for example i want only a number between 0 and 1 to get picked and i want to include points like 0.5, but i don't know how this can be doing i wrote the below code but i only get either 0 or 1, and how to change the length of the slider.

              FlutterSlider(
                values: [0.0,1.0],
                max: 1.0,
                min: 0.0,
                onDragging: (handlerIndex, lowerValue, upperValue) {
                  setState(() {});
                },
                handler: FlutterSliderHandler(
                  decoration: BoxDecoration(),
                  child: Material(
                    type: MaterialType.canvas,
                    color: Colors.orange,
                    elevation: 3,
                    child: Container(
                        padding: EdgeInsets.all(5),
                        child: Icon(
                          Icons.brightness_7,
                          size: 25,
                        )),
                  ),
                ),
              )

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.