I installed Awesome Flutter Snippets and Flutter Snippets extension in VS Code. When I install these two extensions, I can use some keyboard shortcuts to generate widgets.
When I type statelessW
or stless
in the code and hit enter, it generates StatelessWidget
like this:
statelessW
:
class name extends StatelessWidget {
const name({super.key});
@override
Widget build(BuildContext context) {
return Container();
}
}
stless
:
class MyWidget extends StatelessWidget {
const MyWidget({super.key});
@override
Widget build(BuildContext context) {
return Container();
}
}
You can see that the above two pieces of code are the same, the two pieces of code use ({super.key});
instead of ({Key? key}) : super(key: key);
.
Is it recommended to use ({super.key});
instead of ({Key? key}) : super(key: key);
in Flutter? I would appreciate any help. Thank you in advance!