Hey 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:
stless to create a Stateless WidgetMyWidget(this.title);MyWidget({Key key, this.title}) : super(key: key);Key and proper call to super.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.
Well, @scheglov what do you think? We already treat Widget subclasses specially in other ways for some assists.
@brianegan Could you please point me out on the "normal Flutter rules", so that I could read more about it?
Ah, I found it.
https://docs.flutter.io/flutter/widgets/StatelessWidget-class.html
By convention, widget constructors only use named arguments. Named arguments can be marked as required using @required. Also by convention, the first argument is key, and the last argument is child, children, or the equivalent.
Yep, that's it! Sorry about the slow response, appreciate ya taking a look at it :)
Omg, amazing. Thanks so much!
How can I view the light bulb? It does not appear on Android Studio on highlight.
@leslieharland Alt + Enter
My newly installed Android Studio / Flutter / Dart does not generate Widget constructors in accordance with Flutter rules, how can I make it do that?
https://stackoverflow.com/questions/62524041/can-i-make-android-studio-generate-dart-constructors-code-with-named-parameters
Most helpful comment
https://dart-review.googlesource.com/c/sdk/+/48700