Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static final RangeThumbSelector _defaultRangeThumbSelector = (
- TextDirection textDirection,
- RangeValues values,
- double tapValue,
- Size thumbSize,
- Size trackSize,
- double dx, // drag displacement
- ) {
- final double touchRadius = math.max(thumbSize.width, RangeSlider._minTouchTargetWidth) / 2;
- final bool inStartTouchTarget = (tapValue - values.start).abs() * trackSize.width < touchRadius;
- final bool inEndTouchTarget = (tapValue - values.end).abs() * trackSize.width < touchRadius;
- if (inStartTouchTarget && inEndTouchTarget) {
- bool towardsStart;
- bool towardsEnd;
- switch (textDirection) {
- case TextDirection.ltr:
- towardsStart = dx < 0;
- towardsEnd = dx > 0;
- break;
- case TextDirection.rtl:
- towardsStart = dx > 0;
- towardsEnd = dx < 0;
- break;
- }
- if (towardsStart)
- return Thumb.start;
- if (towardsEnd)
- return Thumb.end;
- } else {
- if (tapValue < values.start || inStartTouchTarget)
- return Thumb.start;
- if (tapValue > values.end || inEndTouchTarget)
- return Thumb.end;
- }
- return null;
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement