-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix: Sometimes touch is ignored when scrollable sheet reaches edge (#209
) ## Fixes / Closes (optional) Fixes #207. ## Description This PR improves floating-point value comparisons throughout the codebase to address an existing issue and prevent potential problems related to floating-point precision errors. For example, #207 was caused by infinite recursion of `SheetContentScrollPositionOwner.goBallisticWithScrollPosition` calls, triggered by `ScrollMetrics.outOfRange` always being true in `ScrollPhysics.createBallisticSimulation` due to such a floating-point precision error. ## Summary (check all that apply) - [x] Modified / added code - [x] Modified / added tests - [ ] Modified / added examples - [ ] Modified / added others (pubspec.yaml, workflows, etc...) - [ ] Updated README - [ ] Contains breaking changes - [ ] Created / updated migration guide - [x] Incremented version number - [x] Updated CHANGELOG
- Loading branch information
Showing
13 changed files
with
250 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,12 @@ | ||
import 'dart:math'; | ||
|
||
import 'package:flutter/physics.dart'; | ||
|
||
extension DoubleUtils on double { | ||
bool isApprox(double value) => | ||
nearEqual(this, value, Tolerance.defaultTolerance.distance); | ||
|
||
bool isLessThan(double value) => this < value && !isApprox(value); | ||
|
||
bool isGreaterThan(double value) => this > value && !isApprox(value); | ||
|
||
bool isLessThanOrApprox(double value) => isLessThan(value) || isApprox(value); | ||
|
||
bool isGreaterThanOrApprox(double value) => | ||
isGreaterThan(value) || isApprox(value); | ||
|
||
bool isOutOfBounds(double min, double max) => | ||
isLessThan(min) || isGreaterThan(max); | ||
|
||
bool isInBounds(double min, double max) => !isOutOfBounds(min, max); | ||
|
||
double clampAbs(double norm) => min(max(-norm, this), norm); | ||
|
||
double nearest(double a, double b) => | ||
(a - this).abs() < (b - this).abs() ? a : b; | ||
} | ||
|
||
double inverseLerp(double min, double max, double value) { | ||
return min == max ? 1.0 : (value - min) / (max - min); | ||
double inverseLerp(double min, double max) { | ||
return min == max ? 1.0 : (this - min) / (max - min); | ||
} | ||
} |
Oops, something went wrong.