"Create Constructor" for Widgets
See original GitHub issueHey hey 😃 I find myself creating a lot of Widget constructors, and I end up repeating the same manual process over and over. I thought it might be cool if this could be part of the Flutter IntelliJ plugin!
tl;dr – “Create Constructor” should produce an idiomatic constructor for Widgets.
Full Steps:
- type
stless
to create a Stateless Widget - Add a final field to the Widget
- Put cursor over the final field
- Alt-Enter
- Select “Create Constructor for Final Field”, produces:
MyWidget(this.title);
- Change this to conform with the normal Flutter rules:
MyWidget({Key key, this.title}) : super(key: key);
- All fields optional
- Includes a
Key
and proper call tosuper
.
Not a huge deal, but I’ve done it so much recently I thought it’d be nice if it could be generated for me 😃 Thanks again for all the hard work – the plugin is getting sooooo good.
Issue Analytics
- State:
- Created 5 years ago
- Comments:10 (6 by maintainers)
Top Results From Across the Web
StatelessWidget class - widgets library - Flutter - Dart API docs
Use const widgets where possible, and provide a const constructor for the widget so that users of the widget can also do so....
Read more >Flutter Dart constructor - Stack Overflow
It is the constructor of the Align widget. class Align extends SingleChildRenderObjectWidget { // constructor const Align({ Key key, // named ...
Read more >Flutter: Passing Widgets using Constructor Arguments in ...
In this video, I'll talk about how we can use constructor arguments to pass widgets while creating Stateless and Stateful widgets.
Read more > Flutter| Using Super Constructor in Custom Widget Design ...
We will take care to write clean code while creating custom widgets. The important part is how to use the “Super Constructor” that...
Read more >Custom Constructors for StatefulWidgets? - Google Groups
Therefore, I have custom constructor for this widget that takes in a DateTime object, ... of the SDK authors to create so many...
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
https://dart-review.googlesource.com/c/sdk/+/48700
@leslieharland Alt + Enter