Skip to content
This repository has been archived by the owner on Oct 17, 2024. It is now read-only.

Add explicit generics to Future.sync calls #110

Merged
merged 1 commit into from
Mar 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/src/async_memoizer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class AsyncMemoizer<T> {
///
/// If [runOnce] has already been called, this returns the original result.
Future<T> runOnce(FutureOr<T> Function() computation) {
if (!hasRun) _completer.complete(Future.sync(computation));
if (!hasRun) _completer.complete(Future<T>.sync(computation));
return future;
}
}
6 changes: 3 additions & 3 deletions lib/src/cancelable_operation.dart
Original file line number Diff line number Diff line change
Expand Up @@ -105,17 +105,17 @@ class CancelableOperation<T> {
valueOrCancellation().then((T result) {
if (!completer.isCanceled) {
if (isCompleted) {
completer.complete(Future.sync(() => onValue(result)));
completer.complete(Future<R>.sync(() => onValue(result)));
} else if (onCancel != null) {
completer.complete(Future.sync(onCancel));
completer.complete(Future<R>.sync(onCancel));
} else {
completer._cancel();
}
}
}, onError: (Object error, StackTrace stackTrace) {
if (!completer.isCanceled) {
if (onError != null) {
completer.complete(Future.sync(() => onError(error, stackTrace)));
completer.complete(Future<R>.sync(() => onError(error, stackTrace)));
} else {
completer.completeError(error, stackTrace);
}
Expand Down