Open
Description
Issue description
The return type generated by quickfix in vscode, studio or dartpad for the following async function is Future<String?>?
. In my opinion, it should be Future<String?>
instead, as an async function would always return a Future and never null.
returnStringOrNull() async
{
return Random().nextBool() ? "OK" : null;
}
Dart SDK version: 3.2.6 (stable) (Wed Jan 24 13:41:58 2024 +0000) on "macos_x64"
Steps to replicate
Here is a dartpad showing the same issue - https://dartpad.dev/?id=0e8505321de7157abe72675f4e1ab073
Right click on returnStringOrNull
and then select Add return type
. The resulting code is
Future<String?>? returnStringOrNull() async
{
return Random().nextBool() ? "OK" : null;
}