Skip to content

Commit

Permalink
Merge pull request #22 from YasufumiMuranaka/master
Browse files Browse the repository at this point in the history
fix: selectByTap doesn't work by actual Android devices
  • Loading branch information
loonix authored Mar 29, 2023
2 parents 5673833 + 0fa59dc commit d415ee6
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions lib/another_xlider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,9 @@ class FlutterSliderState extends State<FlutterSlider> with TickerProviderStateMi
// Flag for whether trackBarSlideOnDragStarted() was called
bool _trackBarSlideOnDragStartedCalled = false;

// Flags for selectByTap propery handring for Android actual devices
bool isPointerDown = false;

@override
void initState() {
initMethod();
Expand Down Expand Up @@ -976,6 +979,8 @@ class FlutterSliderState extends State<FlutterSlider> with TickerProviderStateMi

if (selectedByTap) {
_callbacks('onDragStarted', 0);
} else if (!isPointerDown) {
return;
}

bool validMove = true;
Expand Down Expand Up @@ -1196,6 +1201,8 @@ class FlutterSliderState extends State<FlutterSlider> with TickerProviderStateMi

if (selectedByTap) {
_callbacks('onDragStarted', 1);
} else if (!isPointerDown) {
return;
}

bool validMove = true;
Expand Down Expand Up @@ -1487,7 +1494,7 @@ class FlutterSliderState extends State<FlutterSlider> with TickerProviderStateMi
},
onPointerDown: (_) {
if (widget.disabled || (widget.handler != null && widget.handler!.disabled)) return;

isPointerDown = true;
_renderBoxInitialization();

xDragTmp = (_.position.dx - _containerLeft - _leftHandlerXPosition!);
Expand All @@ -1510,7 +1517,7 @@ class FlutterSliderState extends State<FlutterSlider> with TickerProviderStateMi
_callbacks('onDragStarted', 0);
},
onPointerUp: (_) {
__dragging = false;
__dragging = isPointerDown = false;

_adjustLeftHandlerPosition();

Expand Down Expand Up @@ -1597,7 +1604,7 @@ class FlutterSliderState extends State<FlutterSlider> with TickerProviderStateMi
if (widget.disabled || (widget.rightHandler != null && widget.rightHandler!.disabled)) {
return;
}

isPointerDown = true;
_renderBoxInitialization();

xDragTmp = (_.position.dx - _containerLeft - _rightHandlerXPosition!);
Expand All @@ -1623,7 +1630,7 @@ class FlutterSliderState extends State<FlutterSlider> with TickerProviderStateMi
_callbacks('onDragStarted', 1);
},
onPointerUp: (_) {
__dragging = false;
__dragging = isPointerDown = false;

_adjustRightHandlerPosition();

Expand Down

0 comments on commit d415ee6

Please sign in to comment.