-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #50 from solid-software/feat/intelligent-highlight-2
Feat/Intelligent highlight
- Loading branch information
Showing
7 changed files
with
158 additions
and
12 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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import 'dart:math'; | ||
|
||
/// The [ClosedRange] class represents a closed range of integers, defined | ||
/// by a starting point and an ending point. | ||
/// The start and end properties represent the bounds of the range. | ||
class ClosedRange { | ||
/// The start of the closed range. | ||
final int start; | ||
|
||
/// The start of the closed range. | ||
final int end; | ||
|
||
/// Constructor for creating a ClosedRange object | ||
const ClosedRange(this.start, this.end); | ||
|
||
/// Checks if the given point is before or at the range | ||
bool isBeforeOrAt(int point) => point <= min(start, end); | ||
|
||
/// Checks if the given point is after or at the range | ||
bool isAfterOrAt(int point) => point >= max(start, end); | ||
|
||
/// Checks if the range contains the given point | ||
bool contains(int point) { | ||
return start <= point && point <= end; | ||
} | ||
|
||
/// Checks if the this range is within the boundaries of the another range | ||
bool overlapsWith(ClosedRange other) { | ||
return contains(other.start) || contains(other.end); | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import 'package:async/async.dart'; | ||
|
||
/// A service that executes asynchronous operations and ensures that only | ||
/// the results of the latest operation are returned. | ||
class KeepLatestResponseService { | ||
CancelableOperation<dynamic>? _currentOperation; | ||
|
||
/// Executes the latest operation and returns its result. | ||
/// Only the results of the most recent operation are returned, | ||
/// discarding any previous ongoing operations. | ||
Future<T?> processLatestOperation<T>(Future<T> Function() action) async { | ||
final newOperation = CancelableOperation<T>.fromFuture(action()); | ||
await _currentOperation?.cancel(); | ||
_currentOperation = newOperation; | ||
|
||
return _currentOperation?.value as Future<T>?; | ||
} | ||
} |
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