Describe the bug
In a build function, when calling extract method on a widget such as a button with an asynchronous callback (e.g. async onPressed method), the newly created method itself is marked as an async function, which is incorrect (at least in all the cases that I've used it). While the callback is asynchronous, the function that is returning the widget should not be.
To Reproduce
Steps to reproduce the behavior:
- Create a widget such as a button with an asynchronous callback. For example:
ListTile(
title: "Hi",
suffixIcon: IconButton(
onPressed: () async {
await asyncFunction()
},
icon: Icon(Icons.arrow_forward),
)
)
-
Place your cursor on IconButton, bring up the context menu, press extract method, and name the new function.
-
The IconButton will have been replaced by your new method, but it has an await keyword before it that should not be there.
Expected behavior
The new function is added in place of the IconButton without an await in front of the function call. The new function does not return a Future<Widget> but just a Widget. The new method is not an async method.
Please complete the following information:
- Operating System and version: macOS Monterey 12.2, M1 Chip
- VS Code version: 1.68.1
- Dart extension version: v3.44.0
- Dart/Flutter SDK version: Flutter 2.10.4, Dart 2.16.2
Describe the bug
In a build function, when calling extract method on a widget such as a button with an asynchronous callback (e.g. async
onPressedmethod), the newly created method itself is marked as anasyncfunction, which is incorrect (at least in all the cases that I've used it). While the callback is asynchronous, the function that is returning the widget should not be.To Reproduce
Steps to reproduce the behavior:
Place your cursor on
IconButton, bring up the context menu, pressextract method, and name the new function.The
IconButtonwill have been replaced by your new method, but it has anawaitkeyword before it that should not be there.Expected behavior
The new function is added in place of the
IconButtonwithout anawaitin front of the function call. The new function does not return aFuture<Widget>but just aWidget. The new method is not anasyncmethod.Please complete the following information: