Skip to content

Commit

Permalink
feat: added takeAtLeast extension for Future
Browse files Browse the repository at this point in the history
  • Loading branch information
vanlooverenkoen committed Dec 25, 2024
1 parent 7ab6100 commit 6cbe006
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# 0.7.0

## Feat

- Added takeAtLeast extension for Future

# 0.6.0

## Feat
Expand Down
9 changes: 9 additions & 0 deletions lib/src/extension/future_extension.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
extension FutureExtensions<T> on Future<T> {
Future<T> takeAtLeast(Duration duration) async {
final result = await Future.wait([
this,
Future.delayed(duration),
]);
return result.first as T;
}
}

0 comments on commit 6cbe006

Please sign in to comment.