Skip to content
This repository was archived by the owner on Jul 16, 2023. It is now read-only.

fix(avoid-passing-async-when-sync-expected): FutureOr Functions are… #1036

Merged
merged 1 commit into from
Oct 14, 2022
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 4.21.2

* fix(avoid-passing-async-when-sync-expected): FutureOr Functions are interpreted as synchronous functions

## 4.21.1

* fix: stop plugin flickering after migration to new api.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ class _Visitor extends RecursiveAstVisitor<void> {
final parameterType = argument.staticParameterElement?.type;
if (argumentType is FunctionType && parameterType is FunctionType) {
if (argumentType.returnType.isDartAsyncFuture &&
!parameterType.returnType.isDartAsyncFuture) {
(!parameterType.returnType.isDartAsyncFuture &&
!parameterType.returnType.isDartAsyncFutureOr)) {
_invalidArguments.add(argument);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,10 @@ class _MyHomePageState extends State<MyHomePage> {
),
);
}

Future<String> doSomeGetRequest() => Future.value('');

Future<String> doAnotherGetRequest(String input) => Future.value('');

Future<String> main() => doSomeGetRequest().then(doAnotherGetRequest);
}