I don't know if this is VSCode feature request or specifically for dart/flutter, but is it possible to move a widget class (or any other class) to a new file? If I remember correctly Visual Studio have this refactoring option.
Say I have this my_widget.dart file.
class MyWidget extends StatelessWidget {
const MyWidget({Key key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Container(
child: child,
);
}
}
class MyOtherWidget extends StatelessWidget {
const MyOtherWidget({Key key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Container(
child: child,
);
}
}
I want to move MyOtherWidget to my_other_widget.dart (automatically created) and automatically import that file if my_widget.dart contains MyOtherWidget references. Sorry if this is a duplicate.
Thank you.
This requires support in the SDK's analysis server before it can be supported here. There's an open issue for it you can 馃憤 and subscribe to at https://github.com/dart-lang/sdk/issues/30310.
If it's added to the server, then it could be exposed here in VS Code.
Wow that issue is almost 2 years old 馃槄
Yeah, it only has 3 馃憤's including yours. I don't think it's in huge demand (probably mostly because people tend to put many classes per file).
Well 11馃憤 now ;)
I really wish to have way more refactorings for dart and this is one that I would honestly use very often.
12+ now :) Refactoring is all we need to be code boy scouts. Any news on this feature @DanTup ?
This would first need to be implemented in the analyzer in the SDK (https://github.com/dart-lang/sdk/issues/30310). Once implemented there, it would be available to both VS Code and IntelliJ/Android Studio extensions to expose in the UI.
Now there are 66, will there be any updates now?
As mentioned above, this can't be implemented here until it's available in the server. There was a response posted on the SDK issue last month:
https://github.com/dart-lang/sdk/issues/30310#issuecomment-636934708
Most helpful comment
This requires support in the SDK's analysis server before it can be supported here. There's an open issue for it you can 馃憤 and subscribe to at https://github.com/dart-lang/sdk/issues/30310.
If it's added to the server, then it could be exposed here in VS Code.