Refactoring - Move Widget/Class to New File
See original GitHub issueI 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.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:162
- Comments:11 (4 by maintainers)
Top Results From Across the Web
Flutter Refactoring move widgets to new files - Stack Overflow
I want to move its children to new files. I already have Widget TabContent1 and Widget TabContent2 in the same class, but how...
Read more >Move Type to Another File refactoring - JetBrains Rider
Move a type to another file · Press Ctrl+R, O and then choose Move to Another File · Press Ctrl+Shift+R and then choose...
Read more >How refactoring improve readability, maintainability and ...
3. Refactoring with a widget class · Open the any . · Place the cursor on the first widget and right-click, in my...
Read more >Refactorings and Code Fixes
leadingNewlineToString.multi - Add leading new line everywhere in file; quickfix.add. ... moveTypeArgumentsToClass - Move type arguments to after class name ...
Read more >Flutter Tutorial for Beginners #20 - Extracting Widgets - YouTube
Hey gang, in this Flutter tutorial I'll show you how you can extract widget trees into their own re-usable class widget.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Any updates? It would be useful during refactor of legacy code for us
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.