Convert to StatefulWidget adds an extra underscore to private widgets
See original GitHub issueDescribe the bug
If you have a private StatelessWidget
that you’d like to turn into a StatefulWidget
, when you using the VS Code helper to do so your new State
class will be prefixed with an extra underscore:
For example, if your class name was _MyCustomWidget
, when using Convert to StatefulWidget the new state generated will be__MyCustomWidgetState
(notice the two underscores at the beginning)
To Reproduce
- Create a private
StatelessWidget
- Click on
Convert to StatefulWidget
and see the new state being prefixed by 2 underscores.
Expected behavior The new state generated only has one underscore.
Versions (please complete the following information):
- VS Code version: 1.56.2
- Dart extension version: 3.22.0
- Dart/Flutter SDK version: Flutter (Channel beta, 2.2.0-10.3.pre, on macOS 11.2.3 20D91 darwin-x64, locale en-US)
Issue Analytics
- State:
- Created 2 years ago
- Comments:12 (5 by maintainers)
Top Results From Across the Web
Converting a Stateful Widget App to Using Provider for State ...
Move your image_picker import to your state file; Remove the underscore in the function names so they're no longer private; Delete the setState ......
Read more >Google Flutter - Stateful Widgets - Jilli Boutique
Code in this class can refer to Stateful Widget by using the 'widget' variable. Sometimes this class uses an underscore prefix in its...
Read more >Keeping final fields on the Widget or the State? - Stack Overflow
The StatefulWidget 's associated State should use only the default constructor (no arguments), and its member fields should be private ...
Read more >Flutter: State Management with Stateful Widgets
A stateful widget can change its appearance in response to user ... This returned widget gets added as a child to the parent...
Read more >Adding interactivity to your Flutter app
A stateful widget is dynamic: for example, it can change its appearance in ... Note: Members or classes that start with an underscore...
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
Wohooo! Thank you @MrBirb !!!
I have a PR submitted https://dart-review.googlesource.com/c/sdk/+/200720