Issue
This Content is from Stack Overflow. Question asked by Gwhyyy
I want to know what’s the main difference between using super.key
and (Key? key) : super(key: key)
in a flutter app, I mean I know they both set key from the super widgets, but why there is 2 types of them, and which is preferred to use.
Solution
super.key
is the new syntax, made available in Dart 2.17, which first came with Flutter 3.0. Details are at the release notes: https://dart.dev/guides/whats-new#may-11-2022-217-release
The new syntax is much shorter and cleaner, but you’ll need to understand both forms for years to come.
This Question was asked in StackOverflow by Gwhyyy and Answered by Randal Schwartz It is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.